首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-04-11 
【SQL达人们来帮帮忙哦】SQL codeselect top + NUMCount + * from tb_Student whereID not in ( select t

【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

热点排行