谢谢. 在我给的那个URL里有一个user comment不错: frumler at the-beach dot no_spam dot net 04-Aug-2001 11:17 If you want to use the ID that was generated for one table and insert it into a second table, you can use SQL statements like this: INSERT INTO foo (auto,text) VALUES(NULL,'text'); # generate ID by inserting NULL INSERT INTO foo2 (id,text) VALUES(LAST_INSERT_ID(),'text'); # use ID in second table ...found here: http://www.mysql.com/doc/en/Getting_unique_ID.html 我决定用这种方法.
不会有紊乱的情况吧? 有没有可能一下插两个表的技术或者更好的表设计?
http://cn.php.net/manual/zh/function.mysql-insert-id.php
frumler at the-beach dot no_spam dot net
04-Aug-2001 11:17
If you want to use the ID that was generated for one table and insert it into a second table, you can use SQL statements like this: INSERT INTO foo (auto,text)
VALUES(NULL,'text'); # generate ID by inserting NULL
INSERT INTO foo2 (id,text)
VALUES(LAST_INSERT_ID(),'text'); # use ID in second table ...found here:
http://www.mysql.com/doc/en/Getting_unique_ID.html
我决定用这种方法.