Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-08-2002, 11:21 PM   PM User | #1
reub77
New Coder

 
Join Date: Sep 2002
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
reub77 is an unknown quantity at this point
How can I add to 3 different tables in the same query?

This is the segment of the code:

<?PHP
if($Submit){
//formulate a jobID
include("jobID.php");
$conn = db_connect();
//declare query
$query = ('INSERT INTO currProjects (id,companyName,contact,phoneNum,email,url,street,
city,provState,country,postalCode,jobSummary,contr
actStatus,status) VALUES ("'.$jobID.'","'.$company.'","'.$cont.'","'.$phone.'","'.$Email.'","'.$URL.'","'.$Street.'","'.$City .'","'.$prov.'","'.$Country.'","'.$postal.'","'.$jobSum.'","none","lead"); INSERT INTO contracts (id) VALUES ("'.$jobID.'"); INSERT INTO invoices (id) VALUES ("'.$jobID.'")';
//execute query
$result = mysql_query($query);
}
?>

I know there is an easier way to do this but I just don't know it. Please teach me.

Thanks
reub77 is offline   Reply With Quote
Old 10-09-2002, 11:29 AM   PM User | #2
Dylan Leblanc
Regular Coder

 
Join Date: Sep 2002
Location: British Columbia
Posts: 235
Thanks: 0
Thanked 0 Times in 0 Posts
Dylan Leblanc is an unknown quantity at this point
I am not sure on this, but I thing you can do JOIN's for this.
Dylan Leblanc is offline   Reply With Quote
Old 10-09-2002, 04:13 PM   PM User | #3
reub77
New Coder

 
Join Date: Sep 2002
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
reub77 is an unknown quantity at this point
Joins?

I've heard of joins and I think they would be wonderful if I knew how to do them. Can somebody show me what a join would look like for this example and I'd like to understand when you should use them?
reub77 is offline   Reply With Quote
Old 10-09-2002, 07:56 PM   PM User | #4
Dylan Leblanc
Regular Coder

 
Join Date: Sep 2002
Location: British Columbia
Posts: 235
Thanks: 0
Thanked 0 Times in 0 Posts
Dylan Leblanc is an unknown quantity at this point
Hi, sorry. On second thought it now seems kind of strange to try and do a join with an insert. Doing 3 inserts at once really ain't that bad. I dont know whaere I am going anymore.
Dylan Leblanc is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:43 AM.


Advertisement
Log in to turn off these ads.