Can anybody tell me the query for last inserted value in the column of the database.
The problem is that inserted value can be placed in inner rows of the database after using ASC or DESC so I cant use the method. If anybody has the solution please tell me.
You will need to use a
TIMESTAMPdata column in order to keep track of insertion time. Unfortunately, due to inherent race conditions, using auto-incrementing primary keys will not work in this case. Simply add the entry timestamp as a data column and retrieve withORDER BY time_stamp DESC LIMIT 1to get the last record. If you’re feeling really defensive, aim to include conditions in theWHEREclause that are unique to the originalINSERTcall (i.e.,WHERE ID = x AND KEY = y)