LAST_INSERT_ID(expr) を使う方法 公式ドキュメントで紹介されている方法. MySQL 5.6 Reference Manual :: 12.14 Information Functions LAST_INSERT_ID(), LAST_INSERT_ID(expr) 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: テーブル準備 採番テーブル