This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes select statement for three column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "select statement for three column" Watch "select statement for three column" New topic
Author

select statement for three column

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1240
there are three colums in my database table.i need to write a select statement for related to all three columns.

boolean isPresent=statement.execute("SELECT PERSON FROM ID WHERE "
+ "ID=1"
+ "AND (Address=\'abc\'AND lastName=\'xxxx\')");

is this correct?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43980
    
  33
Difficult to tell, because I don't know what your columns are. The SQL string looks like well-formed SQL, so you will have to try and see what happens when you execute that query at the command line? Have you read the API for java.sql.Statement#execute()?

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32481
    
214

aruna sameera wrote:is this correct?

It's really close. If you look at the statement as one string you have:


Note the missing space before "and". This means your database can't parse the query.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: select statement for three column
 
It's not a secret anymore!