Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: scratch head to the SQL statement of where 1=1

Re: scratch head to the SQL statement of where 1=1

From: Jitesh Chheda <jiteshpc_at_hotmail.com>
Date: Fri, 07 Sep 2001 14:21:15 +1000
Message-ID: <3B984B3A.ADDD1FF0@hotmail.com>

Katak wrote:

> dear all,
>
> i am having problems understanding a particular SQL statement
> let me paint this scenario to u
>
> SQL statement 1 = select count(*) from mytable
>
> when SQL statement 1 is executed, the value returned is X for example.
>
> SQL SQL statement 1 = select count(*) from mytable where 1=1
> this will also return a value of X.
>
> anyone can enlighten me on this? thanks
> the database used is Oracle 8.1.7

When you say where 1=1 .. the statement behaves as if it did not have a where clause... since for all the rows in any table this conditon is always TRUE..
and hence both the SQLs return the total no of rows in the table...

particularly used with columns that could have null values ... like WHERE column X = NVL( 'Y', column X) .....

HTH Jitesh Received on Thu Sep 06 2001 - 23:21:15 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US