Search code examples
phpmysqlresultsetrelationalrelational-database

Last results submitted in mysql db


How would i get the last 20 results submitted in a mysql db row.

I need the 20 most recent user submitted results.

Cheers.


Solution

  • If you are using an auto_increment primary key, its as simple as:

    SELECT * FROM that_table
    ORDER BY auto_increment_primary_key DESC
    LIMIT 0, 20