Select top 1 and top 2-6 records from MySQL
Posted: Sat Jul 05, 2008 3:16 pm
Hi all,
I am in need of two queries from the same table. I have an ID which is an auto incremented number. There will be some gaps in the ID range.
Query 1,
I want to pull the record with the highest ID
i.e. I have records 1,3,4,6,7,9,11,15,18,20,23 I only want to pull ID 23
Query 2,
I want to pull the next five records
i.e. 23,20,18,15 and 11
I hope this makes sense to someone.
Thanks in advance
I am in need of two queries from the same table. I have an ID which is an auto incremented number. There will be some gaps in the ID range.
Query 1,
I want to pull the record with the highest ID
i.e. I have records 1,3,4,6,7,9,11,15,18,20,23 I only want to pull ID 23
Query 2,
I want to pull the next five records
i.e. 23,20,18,15 and 11
I hope this makes sense to someone.
Thanks in advance