aspose file tools*
The moose likes JDBC and the fly likes how to use 'where' clause Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to use Watch "how to use New topic
Author

how to use 'where' clause

gaurav chhabra
Ranch Hand

Joined: Jul 24, 2004
Posts: 109
sir i m using MS ACCESS and writing the query...

String query = "select * from general_information where id = '" + id5+ "'";

id is "int" and id5 is also an "int"....

id5 is a variable....of int type
but if i write the above query then it is giving no result but if i m writing ...

String query = "select * from general_information where id = 10 ";

then it is working........

please tell me for the query........
thank you
gaurav
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
try to remove ' '


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1129

Gaurav,
In my opinion, better to use a "PreparedStatement".
[NOTE: Below code is uncompiled and untested.]

Good Luck,
Avi.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Actually, integer/number literals should not be in single quotes. Better use PreparedStatement, as said earlier.

By the way, why you kept "id5" in single quotes and "10" without quote, both are integers/numbers though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use 'where' clause