Reputation: 13
I have some questions about syntax on mysql. Is it possibly to know last insert data on mysql with sql command in terminal or not? If possibly just write me thanks for all hints.
Upvotes: 1
Views: 61
Reputation: 3484
You can use this:
$sql = 'SELECT user_id FROM my_users_table ORDER BY user_id DESC LIMIT 0,1';
Upvotes: 1
Reputation: 5764
You can get last inserted ID using LAST_INSERT_ID()
Reference: http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html
Upvotes: 1
Reputation: 657
insert into table (field) values (value);
SELECT @iLastId := LAST_INSERT_ID();
Upvotes: 2