Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two (or more) tables by UPDATE/INSERT query

Status
Not open for further replies.

joep

Programmer
Jun 4, 2000
15
NL
Hello,

With the following string you can update/fill a table:
-------------
$sql = "INSERT INTO tableA (name,address,fax,email) VALUES
('$name','$address','$fax','$email')";
-------------
That's easy ands works. But now i want to insert values to another table at the same time. I tried something like this:
-------------
$sql = "INSERT INTO tableA, tableB (name,address,fax,email,valueB) VALUES
('$name','$address','$fax','$email','$valueB')WHERE tableA_id = tableB_id ";
-------------
But that won't work. Who can help me?
Greets,

Joep
[sig][/sig]
 
Hi Joep,
I don't think that's ever going to work.
You're going to have to redesign your database
as your current design hasn't been normalized.

I recommend.

-creat a autoincremnt ID in tableA
-insert data into tableA
-retrieve newly created autoincrement ID
an insert into tableB

cheers
[sig]<p>Ken<br><a href=mailto:admin@mysqlwebring.com>admin@mysqlwebring.com</a><br><a href= Webring</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top