我有一行可以使用以下命令进行SELECT:
SELECT * FROM uploads WHERE upload_id = $upload_id
但我也想获得下一行的5行。使用PHP,我该怎么做?订单无关紧要。
答案 0 :(得分:1)
获取该记录以及接下来的5个升序upload_ids:
SELECT *
FROM uploads
WHERE upload_id >= $upload_id
ORDER BY upload_id ASC
LIMIT 6
答案 1 :(得分:0)
您可以尝试:
select * from uploads where upload_id >= $upload_id order by upload_id asc limit 6;
您还应该真正避免使用select *
,而只指定您需要的字段,即使这是所有字段。这样,如果架构将来发生变化,您就不会返回冗余数据。