的最后3个输入
中选择最后三行
所以我写这个代码:
SELECT * FROM `data` WHERE
`id`=(select max(`id`) from `data`
WHERE `cat`='$data[cat]' and `id` < $data[id])
所以…怎么编辑呢…不仅显示一个结果,还显示$data[id]
试试这个
SELECT * from data WHERE
`cat`='$data[cat]' and `id` < $data[id]
order by id DESC LIMIT 0,3
试试这个
SELECT * FROM `data` id ORDER BY id DESC LIMIT 0 , 3
select 'data'表中插入的最后3行
SELECT * FROM `data` where id IN ( select id from data where `cat`='$data[cat]' and `id` < $data[id]) ORDER BY id DESC LIMIT 0 , 3
第二个sql用于从特定值
Try order by with where子句
SELECT
*
FROM `data`
WHERE `id` < $data[id]
ORDER BY id DESC
LIMIT 0 , 3
将选择id小于data['id']的三行