LAST_INSERT_ID(expr) : LAST_INSERT_ID : Information Functions MySQL TUTORIALS


MySQL TUTORIALS » Information Functions » LAST_INSERT_ID »

 

LAST_INSERT_ID(expr)


mysql>
mysql> CREATE TABLE sequence (id INT NOT NULL);
Query OK, rows affected (0.05 sec)

mysql>
mysql> INSERT INTO sequence VALUES (0);
Query OK, row affected (0.00 sec)

mysql>
mysql> UPDATE sequence SET id=LAST_INSERT_ID(id+1);
Query OK, row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql>
mysql> SELECT LAST_INSERT_ID();
+------------------+
| LAST_INSERT_ID() |
+------------------+
|                |
+------------------+
row in set (0.00 sec)

mysql>
mysql> drop table sequence;
Query OK, rows affected (0.00 sec)

mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Information Functions
» LAST_INSERT_ID