Return a value if no record is found
Encapsulate the query in a sub-query to transform “no row” to a NULL value. I tested and verified this with PostgreSQL, SQL Server and MySQL. Also works with SQLite. SELECT (SELECT id FROM tbl WHERE id = 9823474) AS id; In Oracle you have to select from the dummy 1-row table DUAL like this: SELECT … Read more