1

我有表Context并且Criteria具有多对多关系,所以我创建DetailsContext了存储每个表的 ID 的表。

然后,Context表是空的,Criteria是主表

我有插入上下文的表单,首先我插入Context表以获取 ID(自动增量),而不是选择 ID 表Context并按Criteria顺序 ID DESC 获取最新 ID。然后我插入到DetailsContext表中。

SELECT ID FROM CONTEXT ORDER BY ID DESC我只是用来获取最新的ID不行吗?恐怕很多用户一起访问时它不起作用。

4

1 回答 1

1

If I understand your question correctly, then according to MySQL documentation, you can get the last ID that was inserted into the table with SELECT LAST_INSERT_ID() as long as the id is autogenerated and you are inserting one row per INSERT statement.

于 2012-08-10T03:49:56.427 回答