开发者

How can I insert data into two mysql tables at once using PHP [duplicate]

This question already has answers here: Clos开发者_如何学JAVAed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜