How do get a ID from one table in phpMyadmin and add it to another table field on insert
I am try to add id from one table to another table to give a relationship to the tables. I am doing this on a number of tables on insert of data from a form. Example: person owns and item so item has item and person开发者_如何转开发 ids to link the two, however in some cases I have optional tables so sometimes the ids of those tables will be added to the item table sometimes it will be left null see previous question about this. In my mind doing a select statement to grab ids from other tables then updating the fields that have just been inserted doesn't seem the best way. Anyone got any better ideas on how to do this? Thanks.
You can use the mysql_insert_id() function, which will return the id of the last inserted record.
精彩评论