1 2 Previous Next 22 Replies Latest reply: Jul 23, 2008 3:00 PM by Billy~Verreynne

# Where 1 =1, Where 1 = 2, what does it mean?

Could anyone roughly tell me what does it mean?
• ###### 1. Re: Where 1 =1, Where 1 = 2, what does it mean?
1=1 means true and 1=2 means false
• ###### 2. Re: Where 1 =1, Where 1 = 2, what does it mean?
Thanks. Would you please give me a simple example how to use it?
• ###### 3. Re: Where 1 =1, Where 1 = 2, what does it mean?
Is there any other use, such as 1=0?
• ###### 4. Re: Where 1 =1, Where 1 = 2, what does it mean?
Are these standard PL/SQL or someone just exployed?
• ###### 5. Re: Where 1 =1, Where 1 = 2, what does it mean?
where 1=2

create table t1 as select * from t

t1 will be same as t without data.

where 1=1

I have seen this clause many queries, i am not sure of the reason.
• ###### 6. Re: Where 1 =1, Where 1 = 2, what does it mean?
Do you mean

create table t1 as select * from t where 1=2

will get table without data? How long would it take if t is very large table?
• ###### 7. Re: Where 1 =1, Where 1 = 2, what does it mean?
What result would be, if:

create table t1 as select * from t where 1=1

In addition, to explore your example of "where 1=2", is there any alternative to get same result?
• ###### 8. Re: Where 1 =1, Where 1 = 2, what does it mean?
Yes, create table t1 as select * from t where 1=2 will create a copy of t with no data in it. IT would take about as long to do it that was as it would to do it explicitly as:
`CREATE TABLE t1 (col1 NUMBER, col2 VARCHAR2(10));`
copying the column list from t. The size of the table used in the select is not material because Oracle is smart enough to know that 1=2 will not return any rows from the selected table so will not even try.

Any equality condition of constants will work the same as 1 = 1 e.g. 'fred' = 'fred' or 1999545678342 = 1999545678342. Similarly, any inequlity predicate will work the same as 1=2 e.g. 'fred = 'barney' or 1999545678342 = 66

John
• ###### 9. Re: Where 1 =1, Where 1 = 2, what does it mean?
Thank you so much, John.

According to following link, Where 1 = 2 will forces a full table scan:

http://www.dba-oracle.com/oracle_tips_ault_where_1_equals_2_parallel_.htm

though this concern is not my original question.
• ###### 10. Re: Where 1 =1, Where 1 = 2, what does it mean?
Still confused. Can I use Where 1=0 instead of Where 1=2?

If Where 1=1 means true, then why not completely omit it?
• ###### 11. Re: Where 1 =1, Where 1 = 2, what does it mean?
What is the problem you are trying to solve? Where 1=1 or 1=0 or 1=99999 is just a comparison of values that will evaluate to either true or false.
• ###### 12. Re: Where 1 =1, Where 1 = 2, what does it mean?
Thank you. I think you have answered my question. I actually do not have real world problem, but just want to learn what is Where 1=1 and 1=2. According to you 1 or 2 does not really have any kind of symbolic meaning but just to make up an equation to tell true or fales. That is what I want to know.

Thanks a lot.
• ###### 13. Re: Where 1 =1, Where 1 = 2, what does it mean?
However, you did not tell me why someones use where 1=1. To me, it just does not make sense.
• ###### 14. Re: Where 1 =1, Where 1 = 2, what does it mean?
I have personally never used "where 1=1". I have used "where 1=0" as described above to clone a table without the data but that is it. I can't think of a case where I would use "where 1=1".
1 2 Previous Next