Skip to main content
clean up, clarify title
Source Link
Erwin Brandstetter
  • 641.3k
  • 155
  • 1.1k
  • 1.3k

Best way to select emptycheck for "empty or null value in postgresvalue"

What is best way to check if value is null or empty string in Postgres sql statements  ?

Value can be long expression so it is preferable that it is written only once in check.

Currently I'm using:

coalesce( trim(stringexpression),'')=''

butBut it looks a bit ugly.

stringexpressionstringexpression may be char(n)char(n) column or expression containing char(n)char(n) columns with trailing spaces.

What is best way?

Best way to select empty or null value in postgres

What is best way to check if value is null or empty string in Postgres sql statements  ?

Value can be long expression so it is preferable that it is written only once in check.

Currently I'm using

coalesce( trim(stringexpression),'')=''

but it looks bit ugly.

stringexpression may be char(n) column or expression containing char(n) columns with trailing spaces.

What is best way?

Best way to check for "empty or null value"

What is best way to check if value is null or empty string in Postgres sql statements?

Value can be long expression so it is preferable that it is written only once in check.

Currently I'm using:

coalesce( trim(stringexpression),'')=''

But it looks a bit ugly.

stringexpression may be char(n) column or expression containing char(n) columns with trailing spaces.

What is best way?

Source Link
Andrus
  • 27.3k
  • 65
  • 214
  • 392

Best way to select empty or null value in postgres

What is best way to check if value is null or empty string in Postgres sql statements ?

Value can be long expression so it is preferable that it is written only once in check.

Currently I'm using

coalesce( trim(stringexpression),'')=''

but it looks bit ugly.

stringexpression may be char(n) column or expression containing char(n) columns with trailing spaces.

What is best way?