I am of the attitude, the day you stop learning something is the day you die. I’m not prepared to induce MySQL into both sides of that equation, however some days it never ceases to amaze me what little thing I didn’t know about MySQL.
Today I saw in reviewing SQL statements for an application SELECT LAST_INSERT_ID(). No big deal, that is expected, however I then saw UPDATE … SET id=LAST_INSERT_ID(id+1) WHERE …
Having never seen this syntax I was forced to review it’s usage. See MySQL Documentation
If expr is given as an argument to LAST_INSERT_ID(), the value of
the argument is returned by the function and is remembered as the
next value to be returned by LAST_INSERT_ID(). This can be used
to simulate sequences:
1.Create a table to hold the sequence counter and …
[Read more]