views:

28

answers:

3

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

I need the 20 most recent user submitted results.

Cheers.

+2  A: 

If you don't have timestamp or autoincrement field on that table then you can't.

Otherwise : select * from table order by id desc limit 0,20

Riho
+1  A: 

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
Salman A
for some reason i am only getting one result back when i have 2 results in the database.
Tapha
here is the code "SELECT * FROM table ORDER BY table_id DESC LIMIT 0, 20"
Tapha
that's impossible! you have not specified a `where` clause in the query you just posted so you *should* see upto 20 records
Salman A
No your right. It was infact a quirk in codeigniter that prevented more than one result showing up.
Tapha
A: 

Hi,

See the Query below, there is an function available in mysql syntax below

SELECT FROM ORDER BY DESC LIMIT 0,20

VAC-Prabhu