[thelist] SQL: insert into mutiple tables help

Warden, Matt mwarden at odyssey-design.com
Tue Apr 10 16:58:51 CDT 2001


> How can I insert a new email address into Subscribers and a Subscriber
> foreign key to Subscriptions at the same time? Since INSERT INTO works
with
> only one table, is it possible?

Not really. There are DBMS-specific hacks that you can use if your DBMS has
them.

> Or do I need to insert the email, run
> another query to get the ID of the new Subscriber, and yet another SQL
> statement to insert the SubscriberFK to Subscriptions?

This is the better solution.  However, you may not have to actually use a
separate SQL query to get the FK. What language are you using? What DBMS are
you using?


--
mattwarden
mattwarden.com





More information about the thelist mailing list