求SQL 语句:按数据库顺序显示最后两条记录

来源:百度知道 编辑:UC知道 时间:2024/05/14 22:45:49
如数据库5条记录顺序为A、B、C、D、E,取出D、E,显示顺序为D、E和显示顺序为E、D的两条SQL语句怎么写

select *
from 表名
where 编号 in (d,e)
order by 编号 ————按升序排列

select *
from 表名
where 编号 in (d,e)
order by 编号 desc ————按降序排列

关键要有主键KEY才行

sql="select * for xxx order by [] desc"倒序
sql="select * for xxx order by [] "顺序

select *
from 表名
where 编号 in (d,e)
order by 编号 ————按升序排列

select *
from 表名
where 编号 in (d,e)
order by 编号 desc ————按降序排列

其中编号为主键,每个表中应该都有

你这个问题太特殊化了
楼上的说法差不多