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.
Example query is :
<insert id="insertInto" parameterType="Something" timeout="0">
INSERT INTO something (something) VALUES (#{something})
<selectKey resultType="int">
SELECT LAST_INSERT_ID()
</selectKey>
</insert>
Code:
System.out.println("Id : " + id)
Output:
Id : 1
autoincrement
? – Completion