日期:2014-05-18  浏览次数:20619 次

关于sql 中 数组的查询
如:   select   *   from   student   where   (classID,StudentID)   in   ((1,2),(3,3),(2,3))
这样的查询
不希望用   const(nvarch,   classID)   +   const(nvarch,   StudentID)   组合成一个字符串来判断.

------解决方案--------------------
好像没有...
------解决方案--------------------
select * from student
where classID=1 and StudentID=2
union all
select * from student
where classID=3 and StudentID=3
union all
select * from student
where classID=2 and StudentID=3
------解决方案--------------------
那存储的时候就不要使用数组。
------解决方案--------------------
不支持数组。
------解决方案--------------------
select * from student where (classID,StudentID) in ((1,2),(3,3),(2,3))

不支持.

把((1,2),(3,3),(2,3))放到表里.

col1,col2
select * from student where (classID = col1 and StudentID = col2)
------解决方案--------------------
只能用select * from student where (classID=1 and StudentID=3) or (classID=1 and StudentID=2)这样子,如果是在程序里生成sql语句,可以做个循环,生成后面的条件语句.
------解决方案--------------------
不支持数组吧
------解决方案--------------------
楼主不是想在SQL里玩VB吧~~~