I am generating a SOQL statement dynamically and under certain conditions I want the query to return 0 results.
The best/most concise way that I could come up with to do this is by appending an Id = null
to my query clause as follows:
select Id, Name from Contact where Id = null
Is this the best way to guarantee a query with 0 results?
The reason I ask is because in SQL
you can add an arbitrary comparison of numbers such a 1 = 0
, but this does not seem to work with SOQL
.
where 1=0
work?