Re: Why use it : SELECT 1 FROM DUAL

From: Robert Hanuschke <robert.hanuschke_at_gmail.com>
Date: Thu, 2 Aug 2012 19:56:59 +0200
Message-ID: <CAL6WDh0_PdzYznuAEC9dO3_qoUjjeS2VJfAchkJb6S+CbXFefg_at_mail.gmail.com>



Hi Eriovaldo,
I often encounter another condition very often - "where 1=1". To my understanding, something like that get's added to code so every statement does have a where condition, even if it's of no use like in those two examples.
Then, another condition very easily can be added by suffixing "AND <new condition>" without having to take care if the "where" is already part of the statement or not - it always is.
Might come in handy if you're using some kind of development software to design queries.

Best regards,
Robert
http://robertvsoracle.blogspot.com

On Thu, Aug 2, 2012 at 7:52 PM, Eriovaldo Andrietta <ecandrietta_at_gmail.com>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
>
>
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Aug 02 2012 - 12:56:59 CDT

Original text of this message