Re: Why use it : SELECT 1 FROM DUAL

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.

On 8/2/2012 11:52 AM, Eriovaldo Andrietta wrote:
> Hello friends,> I am analyzing some sql statments and found out in all queries the> developer added the following where clause plus others...>> and exists (select 1 from dual)>>> All queries has this code.>> Is there any good reason to put it in the sql statment ?> Does it improve performance ?>> This is the first time I see it in SQL ?>> Regards> Eriovaldo