Công nghệ,  Lang thang,  Mẹo vặt

Postgres convert empty string to NULL

Table of Content

Postgres convert empty string to NULL

The proper syntax is:

SELECT . . ., NULLIF(columnname, '')
FROM schema.table;

UPDATE schema.table SET columnname=NULL where columnname='';

That is NULLIF() is a function. If you want to return the value, then it needs to be used in the SELECT. Just hanging around after the FROM clause is not valid SQL.


Leave a Reply

Your email address will not be published.