Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我很难获得最后一个插入的字段。
selct scope identity(); SELECT * FROM Person ORDER BY PersonID DESC LIMIT 1
对于 MySQL,在插入之后,您可以尝试这种解决方案:
echo mysql_insert_id($mysql);
如果您稍后回来并想要最后一个 ID,它会更复杂......您可以使用您的解决方案,但没有任何信息告诉您在查询返回的那一刻和您将使用它的那一刻之间插入另一个 ID ...