I have mysql database and I want to get the last ID from field in a table .
example : -
id Value
1 david
2 jone
3 chris
I want a function return 3 if this table exist .
You can use:
SELECT MAX(id) FROM table
If you want to select the ID of the most recently inserted row in a table with an AUTO_INCREMENT column, you will likey be interested in MySQL's LAST_INSERT_ID function.
SELECT id
FROM table
ORDER BY id DESC
LIMIT 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With