Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how to use 'where' clause

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try to remove ' '
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav,
In my opinion, better to use a "PreparedStatement".
[NOTE: Below code is uncompiled and untested.]

Good Luck,
Avi.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic