Re: Why use it : SELECT 1 FROM DUAL
Date: Thu, 2 Aug 2012 13:19:56 -0500
I also use it in debugging and tuning. By putting the Where 1=1 in I can add/comment other conditions testing plans and responses SELECT f1, f2, f3
Changing the conditions just requires adding an and statement or "--" before an existing one.
On Thu, Aug 2, 2012 at 1:00 PM, Tim Gorman <tim_at_evdbt.com> wrote:
> Lots of developers, when generating SQL statements dynamically, use the
> predicate "1 = 1" or something similar so as not to leave an "AND"
> keyword dangling without a predicate. So, for example they'll have an
> IF-THEN-ELSE condition in the code building the SQL statement that
> generates an actual predicate in the THEN condition and hard-codes the
> no-op of "1 = 1" in the ELSE condition.
> It's an artifact of a slightly clumsy programming method, rather than
> any form of optimization.