- SQL code
select top " + NUMCount + " * from tb_Student where ID not in ( select top " + number + " ID from tb_Student where fengcai=" + num + " order by ID desc )and fengcai=" + num + " order by ID desc
请问——我要在 这个 里面 再加一个 城市 来查询 该怎么拼接 我拼接几次 都报了 order 附近错误。
------解决方案--------------------------------------------------------
- C# code
string city = "重庆"; int NUMCount = 10; int number = 100; int num = 5; string s = "select top " + NUMCount + " * from tb_Student where ID not in ( select top " + number + " ID from tb_Student where fengcai=" + num + " order by ID desc ) and fengcai=" + num + " and city='" + city + "' order by ID desc";
------解决方案--------------------------------------------------------
select top "+NUMCount+" from tb_Student where ID not in(select top "+number+" ID from tb_Student where fengcai="+num+" and city='"+重庆+"') and fengcai="+num+" and city='"+重庆+"' order by ID desc