Most databases will accept this:
select * from SomeTable where true
However some databases (eg SQL Server, Oracle) do not have a boolean type. In these cases you may use:
select * from SomeTable where 1=1
BTW, if building up an sql where clause by hand, this is the basis for simplifying your code because you can avoid having to know if the condition you're about to add to a where clause is the first one (which should be preceded by "WHERE"
), or a subsequent one (which should be preceded by "AND"
). By always starting with "WHERE 1=1"
, all conditions (if any) added to the where clause are preceded by "AND"
.