MySQL LIMIT and ORDER BY Problems

wxdqz

New Member
I have a table that I am attempting to present in portions through on a PHP page. Each successive php page show 10 more records from the my table.

My attempts at getting this to work seem to have failed miserably, here is what I am doing:

Here are the 3 SQL queries, one for each page:

SELECT * FROM INFOPAGE ORDER BY DATE LIMIT 0,10
SELECT * FROM INFOPAGE ORDER BY DATE LIMIT 10,10
SELECT * FROM INFOPAGE ORDER BY DATE LIMIT 20,10

As the I page through the 3 PHP pages using the successive Query example above, I find each 10 records shown are sorted, but the the three PHP pages are out of order.

I think that the LIMIT clause is referencing the table's physical row, and not the "virtual" row specified by the ORDER BY clause.

Does anyone know how to make this work correctly? Does it involve changeing the default INDEX, and if so how does one change the default INDEX in MySQL, unfortunately the MySQL Documentation does not touch on this problem.

Thanks.

Shep
 
Back
Top