Reputation: 372
I am having the issue 'you can't specify target table for update in from clause". I know what it means and I've found some solutions but my syntax is just not working, so I'm asking for help. The query I want to run is
("UPDATE people SET isAlive = '1' WHERE family = (SELECT family FROM people WHERE person = :person)")
I've tried using people AS a and the second people AS b but I'm just stumped at this point.
Upvotes: 1
Views: 58
Reputation: 2005
You can do this by joining that table back on itself:
UPDATE people p1
join people p2 on p1.family=p2.family
SET p1.isAlive = '1'
where p2.person= :person
Upvotes: 1