Hey all,
I'm inserting a row into a table, the MySQL table has an AUTO_INCREMENT primary key. The problem is, I need to make an insertion into another table which references the first row I inserted, so I need to know what id was generated. How do you solve this? In PHP I'd just use mysql_insert_id().
Get auto-numbered primary key on insert?
Moderators: gto, cipto_kh, EgonHugeist
You can query for it with same params as for insert and "select id" afterwards , you can use mysql method in sql call "SELECT LAST_INSERT_ID()" or you can use TZUpdateSQL.OnAfterInsertStament Event for mysql only and only available for latest testing branch.
Also see here for detailed discusssion.
http://zeos.firmos.at/viewtopic.php?t=613&highlight=
Also see here for detailed discusssion.
http://zeos.firmos.at/viewtopic.php?t=613&highlight=
fabian