当前位置: 代码迷 >> ASP.NET >> 【SQL达人们来帮帮忙哦】,该怎么解决
  详细解决方案

【SQL达人们来帮帮忙哦】,该怎么解决

热度:3844   发布时间:2013-02-25 00:00:00.0
【SQL达人们来帮帮忙哦】
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
  相关解决方案