当前位置: 代码迷 >> Sql Server >> 怎么用变量代替查询语句的字段名以及字段的值
  详细解决方案

怎么用变量代替查询语句的字段名以及字段的值

热度:173   发布时间:2016-04-27 19:22:40.0
如何用变量代替查询语句的字段名以及字段的值?
String sql="";
String st=request.getParameter ( "selectType" );//字段名
String tj=request.getParameter ( "tj" );//值
要求构造出的SQL语句为:
sql = "select * from student where 字段名 = 值";

请问该怎样构造这个sql语句呢?

------解决方案--------------------
更正
SQL code
sql   ='select   *   from   student   where   ['+字段名+']='''+tj+''''
  相关解决方案