File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes what is the meaning of Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "what is the meaning of "1=1"  in sql statement" Watch "what is the meaning of "1=1"  in sql statement" New topic
Author

what is the meaning of "1=1" in sql statement

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 437
hi, expert here , can someone pls explain what is "1=1" means in SQL statemnet , if you don't mind, kindly pls give some sample ....thank you very much for guidance
Manish Sridharan
Ranch Hand

Joined: Jul 19, 2005
Posts: 64
hi dear,
'1=1' are conditions used in where clause. it is taken as always true condition. Similarly statement like '1=2'or 1=3 etc means condition is false. this statement are used generally where we want to copy structure of the wxisting table but not the content of the table.
suppose we hava table emp(name,age). and it has data also.
we can fire query as
"create table emp1 as select name, age from emp where 1=2;"

Hope u have got ur answer
bye


Manish S.
Anil Kumar Saha
Ranch Hand

Joined: Apr 07, 2004
Posts: 111
This type of trick can used to hack a Database, popularly known as SQL Injection.


Regards,

Anil Kumar Saha
SCJP 1.4
http://www.agilej.blogspot.com/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the meaning of "1=1" in sql statement
 
Similar Threads
Update statement
Need help with callableStatement()
jstl sql action
Oracle Certification [ OCA]
Need Help with pl/sql (Compilation Error)