SELECT LAST_INSERT_ID()

前端 未结 6 1363
臣服心动
臣服心动 2020-12-28 11:05

Can somebody explain how works MySQL function LAST_INSERT_ID(). I\'m trying to get id of last inserted row in database, but every time get 1.

I use mybatis.

6条回答
  •  再見小時候
    2020-12-28 11:27

    I have two solutions, after implements much complicated i find out about second one... I will tell you second which is better one ... It's pretty simple... just in query insert this keyProperty="id" Like this : INSERT INTO something (something) VALUES (#{something}) Query returns id of inserted row Thanks!

提交回复
热议问题