Retrieving last 10 row inserted without auto increment column as well as timestamp fields.?
views:
60answers:
3Retrieve the rows with the highest 10 values of an auto-increment column.
There's no way to do it programmatically. Without an auto-incrementing ID column or a timestamp, there's no way for the database to know which records were inserted last. If you know something about the last ten insertions, like what the data was, then you could manually find them and delete them.
if u have any primary key in your table with a specific format then u can use below steps
for eg u have primary key user_id
user_id
user_1
user_2
user_2
user_3
......
step 1> First count total number of rows from table.
step 2> now use RLIKE or LIKE( i m not sure what exctaly should use) with LIMIT in negative( i think there would be a way to get rows from back)
user_id DESC LIMIT 0,10
OR
u can select all rows and then use array function on results to get last 10 rows.