SQL 列名为变量的简单问题 JSP中<%bumen = request.form("bumen")%>而在数据库中表如下教室号 语文室 政务处 外语组101 是 是 否102 是 否 否103 否 否 是104 否 否 是部门变量值为 "语文室 政务处 外语组" 三个中的一个sql = "select 教室号 from 表 where [bumen] ='是'"这里 [bumen]这个变量怎么写 呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 sql = "select 教室号 from 表 where 政务处 ='是'" sql = "select 教室号 from 表 where [bumen] ='是'".replaceAll("\\Q[bumen]\\E", 你的变量); 连接起来不可以么?sql = "select 教室号 from 表 where "+ bumen + " ='是'"这样应该可以吧 String bumen = ...;sql = "select 教室号 from 表 where [bumen] = '" + bumen + "'"; SQL> declare 2 type testCur is ref cursor; 3 test_cur testCur; 4 cname varchar2(20) :='&dname'; 5 dept_rec dept%rowtype; 6 begin 7 open test_cur for 8 ' select * from dept where '|| cname ||' =''SALES'''; 9 loop 10 fetch test_cur into dept_rec; 11 exit when test_cur%notfound; 12 DBMS_OUTPUT.PUT_LINE('dname: '||dept_rec.dname||' deptno: '||dept_rec.deptno ); 13 end loop; 14 end; 15 16 / dname: SALES deptno: 30 PL/SQL procedure successfully completed 求大神帮我看下是哪里出错 applicationContext.xml获取application.properties全局变量出错 解决方案 sql service 一个数据库 两张表 要求生成的 id不能有重复 毕业设计遇到的一个问题,求解~ 怎样实现点击次数,流量统计 编码异常 关于hibernate的关联映射的问题 关于Double类型的问题 [调查]Taglib在真实项目中运用的广泛程度? [请教]socket建立445端口连接后,怎么获取其文件列表,谢谢 如何将数据库里的数值转化为select 在安装TortoiseSVN 时出现错误
sql = "select 教室号 from 表 where "+ bumen + " ='是'"
这样应该可以吧
String bumen = ...;
sql = "select 教室号 from 表 where [bumen] = '" + bumen + "'";
SQL> declare
2 type testCur is ref cursor;
3 test_cur testCur;
4 cname varchar2(20) :='&dname';
5 dept_rec dept%rowtype;
6 begin
7 open test_cur for
8 ' select * from dept where '|| cname ||' =''SALES''';
9 loop
10 fetch test_cur into dept_rec;
11 exit when test_cur%notfound;
12 DBMS_OUTPUT.PUT_LINE('dname: '||dept_rec.dname||' deptno: '||dept_rec.deptno );
13 end loop;
14 end;
15
16 /
dname: SALES deptno: 30
PL/SQL procedure successfully completed