This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

select statement for three column

 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48415
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic