日期:2014-05-18  浏览次数:20486 次

小弟好急在线等
ID         name       Content
1             a               aa
2             b               bb
3             c               cc
4             d               dd
5             e               ee
6             f               ff


select   *   from   Mess   order   by   ID   desc   limit   0,2
这样的话我找到的数据是
6             f             ff
5             e             ee
请问各位哥哥姐姐我如何让它显示为
5           e             ee
6           f             ff
求求啦,这个是mysql数据库


------解决方案--------------------
declare @ta table(ID int, name varchar(2), Content varchar(5))
insert @ta select 1, 'a ', 'aa '
union all select 2, 'b ', 'bb '
union all select 3, 'c ', 'cc '
union all select 4, 'd ', 'dd '
union all select 5, 'e ', 'ee '
union all select 6, 'f ', 'ff '


select * from (select top 2 * from @ta order by ID desc )ta order by id asc
ReportServer$wuxi
------解决方案--------------------
declare @ta table(ID int, name varchar(2), Content varchar(5))
insert @ta select 1, 'a ', 'aa '
union all select 2, 'b ', 'bb '
union all select 3, 'c ', 'cc '
union all select 4, 'd ', 'dd '
union all select 5, 'e ', 'ee '
union all select 6, 'f ', 'ff '


select * from (select top 2 * from @ta order by ID desc )ta order by id asc

(6 行受影响)
ID name Content
----------- ---- -------
5 e ee
6 f ff

(2 行受影响)

------解决方案--------------------
declare @ta table(ID int, name varchar(2), Content varchar(5))
insert @ta select 1, 'a ', 'aa '
union all select 2, 'b ', 'bb '
union all select 3, 'c ', 'cc '
union all select 4, 'd ', 'dd '
union all select 5, 'e ', 'ee '
union all select 6, 'f ', 'ff '


select * from @ta where id not in (select top 4 id from @ta )--如果id是递增时可以这样用

(6 行受影响)
ID name Content
----------- ---- -------
5 e ee
6 f ff

(2 行受影响)