'unexpected token: INNER required: SET : line: 2
I am trying to update a column in a table (tblStructures.State) when the values exit in another table (tblStructure_merged_new). But the update inner join did not work.
UPDATE `tblStructures`
INNER JOIN tblStructures_merged_new ON `tblStructures`.`Hole` =tblStructures_merged_new.`Hole`
SET `tblStructures`.`State` = '0'
WHERE `tblStructures`.`From_m`= tblStructures_merged_new.`From_m`
AND `tblStructures`.`Struct1` = tblStructures_merged_new.`Struct1`;
The error message is
SQL Error [42581]: UCAExc:::5.0.1 unexpected token: INNER required: SET : line: 2
Any ideas of why is not working?
Solution 1:[1]
Switch order of lines
UPDATE `tblStructures`
SET `tblStructures`.`State` = '0'
FROM `tblStructures`
INNER JOIN tblStructures_merged_new ON `tblStructures`.`Hole` =tblStructures_merged_new.`Hole`
WHERE `tblStructures`.`From_m`= tblStructures_merged_new.`From_m`
AND `tblStructures`.`Struct1` = tblStructures_merged_new.`Struct1`;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jeremy Caney |
