About last_insert_id()

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 关于last_insert_id()

| username: daaxiang

[TiDB Usage Environment] Poc
[TiDB Version] v7.4.0
[Encountered Issue: Phenomenon and Impact]
last_insert_id() does not display as expected:


My operations are as follows:

Shouldn’t the return value of last_insert_id() be 9?

| username: zhanggame1 | Original post link

LAST_INSERT_ID()
If no parameter is provided, LAST_INSERT_ID() returns a BIGINT UNSIGNED (64-bit) value representing the first automatically generated value that was successfully added to the column due to the most recent INSERT statement with AUTO_INCREMENT. If no row was successfully inserted, the value of LAST_INSERT_ID() remains unchanged.

| username: daaxiang | Original post link

Got it, thanks to the person above.

| username: swino | Original post link

:+1:

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.