Reputation: 13
I have one row that i can SELECT with the following command:
SELECT * FROM uploads WHERE upload_id = $upload_id
But I also want to get the 5 next rows. Using PHP, how can i do that? Order doesn't matter.
Upvotes: 0
Views: 63
Reputation: 4799
You can try:
select * from uploads where upload_id >= $upload_id order by upload_id asc limit 6;
You should also really avoid using select *
and instead specify only the fields you need, even if that is all of the fields. That way if the schema changes in the future you aren't returning redundant data.
Upvotes: 0
Reputation: 4795
To get that record and the next 5 ascending upload_ids:
SELECT *
FROM uploads
WHERE upload_id >= $upload_id
ORDER BY upload_id ASC
LIMIT 6
Upvotes: 1