Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001072

[PHP-DB] INSERT with a JOIN From: Steve Fitzgerald (sf <email protected>)
Date: 07/30/01

I'm trying to create an INSERT statement that will change a field in one
table based upon the id defined in another table.

Here is what I tried:

$sql1 = "INSERT INTO $table_name1 (FirstName,LastName,WorkPhone,
HomePhone,EmailName,Birthday)
VALUES
('[$FirstName]','[$LastName]','[$WorkPhone]','[$HomePhone]','[$EmailName]','
[Birthday]')
";

$sql2 = "INSERT INTO $table_name2 (CompanyName,WebSite)
VALUES
('[$CompanyName]','[$WebSite]')

WHERE contacts ON company.CompanyID =
contacts.CompanyID WHERE ContactID='$ContactID'
";

 $result_1 =  <email protected>($sql1,$connection) or die("Couldn't execute
query.");
 $result_2 =  <email protected>($sql2,$connection) or die("Couldn't execute
query.");
 ?>

The goal is based upon a unique field call ContactID I want to be able to
update the CompanyName associated with the ContactID.

For example: ContactID=1 might have an associated CompanyName= Smith, Inc.
What I want to do is UPDATE/INSERT a new CompanyName and have that reflected
by changing the CompanyID associated with the ContactID.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>