Link to home
Start Free TrialLog in
Avatar of panesar
panesar

asked on

Insert data into multiple tables.

can I use the SQL command to insert data into two tables together.  i have two tables A and B. I would live to insert data into field of both tables.  I have recorsets for each table inritistic(basic) data control, but dont know how to insert using data control properties.  I can insert into one table tough.
Avatar of gencross
gencross

If you have two different recordsets, one for each, you can update the fields in the recordset

rs1.field("name").value = "First"
rs1.update

rs2.field("name2").value = "Last"
rs2.update

You can also create two different INSERT or UPDATE statements, one for each table.

INSERT INTO table1 (name) values('First')
INSERT INTO table2 (name2) values('Last')

UPDATE table1 SET name = 'First'
UPDATE table2 SET name2 = 'Last'

Hope this helps


you can only INSERT into a singel table at a time.  It is not possible, with ONE insert statement. to insert data into two or more tables in the same SQL Statement.
ASKER CERTIFIED SOLUTION
Avatar of shyamkumarreddy
shyamkumarreddy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DanRollins
Hi panesar,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept shyamkumarreddy's comment(s) as an answer.

panesar, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange