如何从表中选择特定行?从表中选择特定行
我想做的事情做到像下面这样:
select * from
(select * from tablename1 where type=1 order by id desc)
where rownum = 5
select * from
(select * from tablename1 where type=1 order by id desc)
where rownum = $variable
如何从表中选择特定行?从表中选择特定行
我想做的事情做到像下面这样:
select * from
(select * from tablename1 where type=1 order by id desc)
where rownum = 5
select * from
(select * from tablename1 where type=1 order by id desc)
where rownum = $variable
使用LIMIT
关键字:
SELECT * FROM tablename WHERE (stuff...) LIMIT $rownum,1;
如果通过2号至LIMIT
,它把第一作为偏移和其次作为返回的结果数量(而如果您只传递1个数字,则将其视为多个结果)。因此,要求LIMIT $rownum,1
您将只返回一行,这是位于$ rownum位置的那一行(请记住,行从0开始索引)。
从什么数据库?不同的供应商处理这个不同。 – 2009-08-16 06:33:15
我正在使用mysql db – user156073 2009-08-16 06:41:41