When no AUTO_INCREMENT value has been generated during the current connection, LAST_INSERT_ID() returns . . . . . . . .
A. -1
B. 0
C. 1
D. 2
Answer: Option B
Solution (By Examveda Team)
This question is about how MySQL keeps track of the last value generated by the AUTO_INCREMENT feature. AUTO_INCREMENT automatically assigns unique numbers to new rows in a table.The LAST_INSERT_ID() function is used to get this last generated value. But what happens if no AUTO_INCREMENT value has been created in the current connection?
The answer is Option B: 0.
In other words, if you haven't added any new rows with AUTO_INCREMENT columns, LAST_INSERT_ID() will return 0 because there is no value to retrieve.

Join The Discussion