How can I insert data into two mysql tables at once using PHP [duplicate]
Possible Duplicate:
mySQL - Insert into three tables
I want to know if I can insert data into two tables using one query in PHP/MySQL?
If it's possible, can I see an example?
No, it is not possible. Mysql INSERT syntax accepts one and only one table as a target
using one query
no
Using one query! I don't think so.
However, I believe that the most appropriate methodology is to utilise transactions. Using transactions, you assure to have data inserted in more than one table (successfully), otherwise any changes are rolled back. That is, either persist all changes or do nothing at all.
精彩评论