469,936 Members | 2,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,936 developers. It's quick & easy.

Inserting into multiple tables using Auto Incremented Field

I'm inserting a record into MySQL 4.0 using Visual Basic ADO. When
using the AddNew and Update method I am unable to retrieve the value
of a Auto incrment field (Yes I know I can MoveLast but this icreases
the update time by a factor of 10 and when your talking about 200,000
inserts its way to long). Is there a way to insert the record into
multiple tables in one statement where you can use the value of the
auto incremented field as the key in the second table? So the
statement inserts the record into a table retrieves the new
auto_incremented key and then insterts information into the second
table using the incremented key as the primary key? Thanks
Jul 20 '05 #1
1 2583
Ryan Hubbard wrote:
inserts its way to long). Is there a way to insert the record into
multiple tables in one statement where you can use the value of the
auto incremented field as the key in the second table? So the


This is possible only with (atleast) two queries.
INSERT INTO foo (auto,text) VALUES(NULL,'text');
INSERT INTO foo2 (id,text) VALUES(LAST_INSERT_ID(),'text');

http://dev.mysql.com/doc/mysql/en/OD...insert_id.html

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Marko Poutiainen | last post: by
2 posts views Thread by Mike N. | last post: by
5 posts views Thread by dos360 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.