PCHomepage
Programmer
I can't seem to work my brain around how to add a second WHERE to a query without breaking it. I am trying to update some records in one table from a different table. The INSERT is working; it's the UPDATE that doesn't look right.
Also, is it possible to be sure that there are no left-overs with the given value that are not being updated by removing them or would it be better to first remove them all, then just simply do an INSERT?
Also, is it possible to be sure that there are no left-overs with the given value that are not being updated by removing them or would it be better to first remove them all, then just simply do an INSERT?
Code:
if (!isset($_SESSION['FileExists'])):
$Query = "INSERT INTO table1
(FileID,
Column2,
Column3)
SELECT UpdateID, Column2, Column3
FROM table2
WHERE Column1 NOT LIKE '%text%'
else:
$Query = "UPDATE INTO table1
SET (Column2,
Column3) =
(SELECT Column2, Column3
FROM table2
WHERE Column1 NOT LIKE '%text%')
WHERE FileID = 1;
endif;