如果我使用这个 SQL:
UPDATE formulare SET EV_id=59, EV_status=5 WHERE EV_id=57 AND ID_uziv=12;SELECT LAST_INSERT_ID();
我会得到0
作为最后插入 id。
我正在使用 PHPmysqli_insert_id
这里说:
The mysqli_insert_id() function returns the ID generated by a query
on a table with a column having the AUTO_INCREMENT attribute.
If the last query wasn't an INSERT or UPDATE statement
or if the modified table does not have a column with the AUTO_INCREMENT attribute,
this function will return zero.
我的桌子formualre
has auto increment
专栏,所以我不知道问题出在哪里
LAST_INSERT_ID()
如果no新的自动增量值已创建。
解决方案是这样的:
UPDATE formulare
SET EV_id=LAST_INSERT_ID(59),
EV_status=5
WHERE EV_id=57
AND ID_uziv=12;
SELECT LAST_INSERT_ID();
注:我想,EV_id
是自动增量主键。
否则你应该执行如下查询:
UPDATE formulare
SET key_col = LAST_INSERT_ID(key_col),
EV_id=59,
EV_status=5
WHERE EV_id=57
AND ID_uziv=12;
SELECT LAST_INSERT_ID();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)