Re: Why use it : SELECT 1 FROM DUAL
- From: Rodd Holman <rodd.holman@xxxxxxxxx>
- To: oracle-l@xxxxxxxxxxxxx
- 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
FROM t1
WHERE 1=1
AND cond1
AND cond2
AND cond3
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@xxxxxxxxx> 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.
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>
--
http://www.freelists.org/webpage/oracle-l
Other related posts: