首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sql 达人指点一上异常句

2012-08-26 
sql 达人指点一下错误句SQL codeSELECT TOP 10 * FROM table WHERE name LIKE $k% AND id NOT IN(SELECT

sql 达人指点一下错误句

SQL code
SELECT TOP 10 * FROM table WHERE name LIKE '$k%' AND id NOT IN(SELECT TOP 10 id FROM table WHERE name LIKE '$k%' ORDER BY LEFT(ltrim(name),1) ORDER BY uptime DESC)


想要先按照更新时间uptime倒序查询 然后分页
不知道哪里有问题

[解决办法]
SQL code
SELECT TOP 10 * FROM table WHERE name LIKE '$k%' AND id NOT IN(SELECT TOP 10 id FROM table WHERE name LIKE '$k%' ORDER BY LEFT(ltrim(name),1)) ORDER BY uptime DESC
[解决办法]
SQL code
SELECT TOP 10 * FROM table WHERE name LIKE '$k%' AND id NOT IN(SELECT TOP 10 id FROM table WHERE name LIKE '$k%' ORDER BY LEFT(ltrim(name),1),uptime DESC)
[解决办法]
SQL code
SELECT TOP 10 * FROM table WHERE name LIKE '$k%' AND id NOT IN(SELECT TOP 10 id FROM table WHERE name LIKE '$k%' ORDER BY LEFT(ltrim(name),1),uptime DESC)
[解决办法]
探讨

谢谢上面几位 现在去掉一个order by 不报错了 但是因为我还一个条件是匹配度 现在查出来的还是按照匹配度的排列结果 没有按照更新时间。。。

热点排行