MySQLで最後にINSERTしたAutoIncrementのidを取得する 生のSQLで取得する場合は、 SELECT LAST_INSERT_ID(); 1 SELECT LAST_INSERT_ID(); で取得できます。 DBIを使用している場合は、以下のようにステートメントハンドルから取得できます。 (この辺で接続処理) : $sth->execute(" INSERT INTO `table_name` (campany, pref) VALUES( 'Igreks Inc.', "東京" ) ") || die $sth->errstr(); my $last_insert_id => $sth->{mysql_insertid}; 12345678 (この辺で接続処理) :$sth->execute(" INSERT INTO `table_name` (campany, pref) VALUES( 'Igreks Inc.', "東京" )") || die $sth->errstr(); my $last_insert_id => $sth->{mysql_insertid}; 参考URL) http://adiary.blog.abk.nu/0259 http://q.hatena.ne.jp/1193324532