如何用变量代替查询语句的字段名以及字段的值?
String sql="";
String st=request.getParameter ( "selectType" );//字段名
String tj=request.getParameter ( "tj" );//值
要求构造出的SQL语句为:
sql = "select * from student where 字段名 = 值";
请问该怎样构造这个sql语句呢?
[解决办法]
更正
sql ='select * from student where ['+字段名+']='''+tj+''''