I have a select query like this:
SELECT n.nid, n.title, n2.nid, n2.title, n2.type
FROM node n
JOIN og_ancestry o ON n.nid = o.group_nid
JOIN node n2 ON n2.nid = o.nid
JOIN og_access_post a ON o.nid = a.nid
JOIN content_type_group c ON n.vid = c.vid
WHERE n.type = 'group'
AND a.og_public = 1
AND c.field_tyyppi_value != 'type1'
I can't figure out how to convert this into update query. I tried like this:
UPDATE og_access_post a
SET a.og_public = 0
FROM node n
JOIN og_ancestry o ON n.nid = o.group_nid
JOIN node n2 ON n2.nid = o.nid
JOIN og_access_post a ON o.nid = a.nid
JOIN content_type_group c ON n.vid = c.vid
WHERE n.type = 'group'
AND a.og_public = 1
AND c.field_tyyppi_value != 'type1'
But I am getting an error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM n.nid, n.title, n2.nid
I have found some solutions but with those I would need to modify the order of my tables and joins. The logic in the select query is right so it makes no sense to me that in order to do update I have to think the logic of the query through again.
How can I convert my query for updating without changing the structure of the query fundamentally?