如何从表MySQL中获取最后插入的id [英] How to get last inserted id from table MySQL
本文介绍了如何从表MySQL中获取最后插入的id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在PHP中运行1个脚本,我需要最后插入ID在订阅表中。
I am running 1 script in php for that I need last inserted id in subscription table. By using that id I want to make notification note for that subscription.
我使用:
SELECT LAST_INSERT_ID() FROM subscription
我得到0,值。
推荐答案
如果使用 php
连接到 mysql
可以使用 mysql_insert_id()
指向最后插入的id。
If you use php
to connect to mysql
you can use mysql_insert_id()
to point to last inserted id.
像这样:
mysql_query("INSERT INTO mytable (1, 2, 3, 'blah')");
$last_id = mysql_insert_id();
请参阅: mysql_insert_id()
这篇关于如何从表MySQL中获取最后插入的id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文