Forum Moderators: coopster
The straight copy/insert I can do for this situation,
<?PHP
$queryINS="INSERT INTO my_TableA (Var1, Var2, Var3...)
SELECT Var1, Var2, Var3... FROM my_TableB
WHERE ID='$unique_ID'";
?>
however attempting to instead UPDATE the information of an existing record in my_tableA with the information in a record in my_tableB has left me stumped. Can someone help me out?
Well you could definitely do the SELECTion first, then pull the result set values into variables and use them to assign new values in a separate UPDATE statement. Or you could do it all in one shot with subqueries:
UPDATE my_TableA SET
Var1 = (SELECT Var1 FROM my_TableB WHERE ID = 1),
Var2 = (SELECT Var2 FROM my_TableB WHERE ID = 1),
Var3 = (SELECT Var3 FROM my_TableB WHERE ID = 1)
WHERE Var1 = 'val01'
;