What is the equivalent of SQLite's IFNULL()
in Postgres?
I have to following query (sqlite in Ruby):
SELECT ifnull(max(code_id) + 1, 1)
FROM configentries
WHERE configtable_id = ...
How should this look like if I want the same result with PostgreSQL?
try coalesce
:
The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null
SELECT coalesce(max(code_id) + 1, 1)
FROM configentries
WHERE configtable_id = ...