473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 2742
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Johan den Boer | last post by:
Hi, How to find out the last insert primary key value when a field is auto incremented. Select the maximum value from the table is not an option because users can add rows very quickly. First...
0
by: Marko Poutiainen | last post by:
Situation: We had to make our SQLServer 2000 database multi-lingual. That is, certain things (such as product names) in the database should be shown in the language the user is using (Finnish,...
5
by: Sparrow | last post by:
I have created a table with the following columns... Date(datetime),Actual (Int),Planned (Int) I need to insert weekending dates starting from 23/04/04 looping thru'for the next 52weeks...
2
by: John Baker | last post by:
Hi: I am combining two tables in a query, extracting some fields, and attempting to create a new table. This process is way down the line form the original tables, and some of the fields were...
2
by: Mike N. | last post by:
Hello- I have a database that uses an auto number field type that goes out of sync periodically. My customer gets a "cannot add record, number already in use" error message. I dump the records...
11
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
5
by: dos360 | last post by:
Hello, I have two tables, one is a list of activities, the other a list of participants. I want to insert one record in the activities table and then using its identity column as foreign key, I...
3
by: simple simon | last post by:
How would I insert into multiple related tables using a table valued parameter? Is there any way to do this without using a WHILE loop? I know how to insert from a table valued parameter into one...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.