Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

select statement for three column

 
Ranch Hand
Posts: 1325
1
  • 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?
 
Marshal
Posts: 69472
277
  • 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()?

 
author & internet detective
Posts: 39997
807
Eclipse IDE VI Editor Java
  • 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.
 
Not so fast naughty spawn! I want you to know about
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic