Query UPDATE people, booths SET booths.status = '2', people.booth_id = (SELECT booths.id FROM booths LEFT JOIN status ON booths.status = status.id WHERE (booths.status = '1' OR booths.status = 0 OR booths.id = people.booth_id) AND booths.id = '25' ) WHERE people.id = '4' AND (booths.status = '1' OR booths.status = 0 OR booths.id = people.booth_id) AND booths.id = '25' Error: You can't specify target table 'people' for update in FROM clause