It appears that the list of columns in the
select
clause insideEXISTS()
subquery is ignored. Is this true?
Yup! All that matters is how many rows it returns.
(Actually, it wouldn't surprise me if some DBMSes do at least evaluate the field-list, even though the values themselves are discarded. So 0 / 0
may not be portable.)
Addendum: I just tested using sqlfiddle.com, and it appears that MySQL treats 0 / 0
as NULL
rather than an error, so that doesn't signify; but even on DMBSes such as Oracle that normally do treat 0 / 0
as an error, the predicate EXISTS (SELECT 0 / 0 ...)
was successful. So, maybe it is portable? (Granted, I only tested a handful of DBMSes — one version each of MySQL, PostgreSQL, Oracle, and SQL Server — so I can't make a guarantee.)