Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql query

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
String gp=request.getParameter("Query");
//how do i give a sql statement like this
select * from tablename where field= gp;
//this does not work why?
 
2 things... you need to make sure that you are not passing the string 'gp' instead of the value of gp. And normally sql statements require 's around string values.

String query = "select * from " + tablename + " where " + field + "='" + gp + "'";

This is if you are using string values. If the field is a numeric field then just don't include the 's.

Regards,
Gerald
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top