I'm making an insert statement, the id field has auto_increment, another field must get the exact same value of the id field.
All I can think of is to create an hash, save it in the insert, then search for it with a select, retrieve the id and then insert it in the proper field.
I am also aware of the LAST_INSERT_ID() command, but I had problem in the past with it.
Are there other ways to achieve this?
Thank you very much
mysql_insert_id()
is the best way to go, unless you're manually making your own ID's.
mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d
", mysql_insert_id());