Search code examples
sqlpostgresqlsql-updatestring-constant

UPDATE table_name SET col_name = varchar WHERE col_name is NULL;


The following UPDATE fails :-

UPDATE table_name SET col_name = varchar WHERE col_name is NULL;

The failure message is :-

ERROR:  column "varchar" does not exist

Whereas the undermentioned one succeeds :-

UPDATE table_name SET col_name = 889977 WHERE col_name is NULL;

I have checked the pg_typeof of the column - col_name is character varying. Kindly help.


Solution

  • i think you missed quote for string

    UPDATE table_name SET col_name = 'varchar' WHERE col_name is NULL;