sql语句 求救!

04-09-27 Javalga
使用sql语句select * from table where xxx=xxx

后边还可以带更多条件如 where xxx=xxx or xxx=xxx1 or xxx=xxx2

如果我一次取得xxx xxx1 xxx2 如何把他赋给sql 语句

倘若用循环

sql="SELECT MineName, SensorNum, Address,SensorCode, RTData, RTStatus, TimeVal, SensorName, Type FROM show_realtime_data where"
下边我该怎么写?          
for (int i = 0; i < info.size(); i++) {
            String kbh = (String) info.get(i);
            query.append(" MineNum= '"+kbh+"' or MineNum = '"+kbh+"'");
          }
            System.out.print(query);
        }

我这样肯定不对

请高手指点一下,谢谢了

Javalga
2004-09-27 11:45
当有好几个条件的时候 or 这里该怎么写啊!!!!

help!!!!!!!!!!!!!

huzhigang
2004-09-27 11:53
可以用“IN”来约束

yi dian ye bu dong
2004-09-29 17:52
substring .... ok?

camellia_me
2004-10-08 20:59
sql="SELECT MineName, SensorNum, Address,SensorCode, RTData, RTStatus, TimeVal, SensorName, Type FROM show_realtime_data where"下边我该怎么写? for (int i = 0; i < info.size(); i++) { String kbh = (String) info.get(i); query.append(" MineNum= '"+kbh+"' or '"); } System.out.print(query); }

sql+=" 1<>1"

猜你喜欢