为什么这SQL句不对,是limit的问题吗
select * from gentie limit 1,6 where tieid=40 order by id desc
我是SQL SERVER,MYSQL下可以用的
[解决办法]
SQL SERVER下不支持limit的
select top 6 * from gentie where tieid=40 order by id desc
[解决办法]
limit 1,6
在MySQL中好象是取第二到第七條紀錄
在MS SQL中就這麼寫
Select TOP 6 * From (select TOP 7 * from gentie where tieid=40 order by id desc) Order By id
[解决办法]
分頁也可以用TOP的,TOP 6不一定就是得到前6條的.
--得到1-6條數據
Select TOP 6 * From gentie where tieid=40 order by id desc
--得到7-12條數據
Select TOP 6 * From (Select TOP 12 * From gentie where tieid=40 order by id desc) Order By id
--得到13-18條數據
Select TOP 6 * From (Select TOP 18 * From gentie where tieid=40 order by id desc) Order By id