Postgres convert empty string to NULL

Table of Contents

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.


https://stackoverflow.com/questions/60580146/postgres-convert-empty-string-to-null

Leave a Reply

Your email address will not be published. Required fields are marked *