I have the following query in PostgreSQL (1=1
is a placeholder for some arbitrary condition as apparently I can't write WHERE TRUE
in Sybase)
SELECT EXISTS FROM (
SELECT 1 FROM someTable WHERE 1=1
)
How do I translate them for SQL Server / Sybase syntax ? A roundabout way is to do:
SELECT COUNT(*) FROM (
SELECT 1 FROM someTable WHERE 1=1
) a
… which can further be simplified to:
SELECT COUNT(*) FROM someTable WHERE 1=1
… but EXISTS
is cleaner and I believe it's in the ANSI standard as well.