...

How can I add to 3 different tables in the same query?

reub77
10-08-2002, 11:21 PM
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

Dylan Leblanc
10-09-2002, 11:29 AM
I am not sure on this, but I thing you can do JOIN's for this.

reub77
10-09-2002, 04:13 PM
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?

Dylan Leblanc
10-09-2002, 07:56 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum