Hi, I would need simply select the last entered row specified by condition,e.g:
SELECT ID from bugs WHERE user=Me
I need to return only the very last ID entered by user 'Me'. Is there any simple way? Thank you
Hi, I would need simply select the last entered row specified by condition,e.g:
SELECT ID from bugs WHERE user=Me
I need to return only the very last ID entered by user 'Me'. Is there any simple way? Thank you
It would be best to have a TIMESTAMP
column that defaults to CURRENT_TIMESTAMP
.. it is the only true predictive behavior you can find here.
The second-best thing you can do is ORDER BY ID DESC LIMIT 1
and hope the newest ID is the largest value.
In concurrency, the latest record may not be the record you just entered. It may better to get the latest record using the primary key.
If it is a auto increment field, use SELECT LAST_INSERT_ID(); to get the id you just created.