tags:

views:

60

answers:

3

Retrieving last 10 row inserted without auto increment column as well as timestamp fields.?

+1  A: 

Retrieve the rows with the highest 10 values of an auto-increment column.

Marcelo Cantos
without auto increment column?
Hari kanna
Anything that increases monotonically, such as a timestamp, will do. If you don't have one of these, then just add one.
Marcelo Cantos
i want to know without auto increment as well as timestamp fields...
Hari kanna
Then no, you can't do it.
Marcelo Cantos
+1  A: 

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.

colinmarc
+1  A: 

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.

diEcho