Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

SQL issues


ghost's Avatar
0 0

i need to take info off of a db from the last rows of a table rather than the first but the table is always growing. How would i get the last rows off the table that i dont know the actual number of? any help is appreciated. thx atrcomb

edit: i forgot to add i have a field in the table that increments with each new addition. If i use ORDER BY how would i get the largest numbers?


ghost's Avatar
0 0

ok assuming you have the incrementing field you have is named id, and you want the last 5 rows, this statement should work

SELECT * FROM table ORDER BY id DESC LIMIT 0,5

i am pretty sure that should work.


ghost's Avatar
0 0

sweet thx chislam

edit: kinda interesting because i did need the last five rows of the field named id…what a coincidence…lol


ghost's Avatar
0 0

:)