We\'re using MySQL with InnoDB storage engine and transactions a lot, and we\'ve run into a problem: we need a nice way to emulate Oracle\'s SEQUENCEs in MySQL. The requirem
The right way to do this is given in the MySQL manual:
UPDATE child_codes SET counter_field = LAST_INSERT_ID(counter_field + 1); SELECT LAST_INSERT_ID();