last_insert_id() vs SELECT Max(ID)

前端 未结 2 1800
你的背包
你的背包 2021-01-23 06:25

Is using SELECT Max(ID) FROM table safer than using SELECT last_insert_id(), where they run as 2 separate queries?

I\'m concerned that before the last_insert_id() can r

2条回答
  •  一向
    一向 (楼主)
    2021-01-23 07:11

    Using select max(id) is just asking for trouble. It's only a matter of time before two inserts would happen near-simultaneously and you would start to see some craziness in your data.

提交回复
热议问题