Re: Why use it : SELECT 1 FROM DUAL
Date: Thu, 2 Aug 2012 19:56:59 +0200
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.
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 ?