Is there anything I can do in SOQL to achieve the same as WHERE 1=1 in regular SQL engines? I've tried that, and WHERE TRUE=TRUE, but it's rejected.


2 Answers 2


All filters are in the form of "field operator value", so the closest approximation would be something like WHERE Id <> NULL, which should be true for most, if not all, objects.

  • We use this sometimes. It is, of course, going to mean a full table scan - indexing won't apply - but then if you are asking for all records, the table needs to be lightly populated anyway!
    – Phil W
    Mar 24 at 18:00
  • I am not sure I understand but in case I want to get all records why are we putting filter in first place?
    – Elijah
    Mar 24 at 19:50

You could also do (for most objects)

WHERE CreatedDate < TOMORROW   returns all objects

WHERE CreatedDate > TOMORROW  returns no objects
  • 1
    I think you meant WHERE CreatedDate < TOMORROW, or alternatively, WHERE CreatedDate != NULL, though I agree overall that CreatedDate is probably a safe bet.
    – sfdcfox
    Mar 24 at 14:28
  • right-o; i misinterpreted the question as wanting the SOQL to fetch nothing
    – cropredy
    Mar 24 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .