I have following SQL query, that does a bulk update on MySQL server:
UPDATE res_booking AS rbg SET rbg.host_id = ( SELECT vw.entity_id FROM res_booking AS rb INNER JOIN pass_single as ps ON (ps.book_id = rb.booking_id) INNER JOIN voucher_who as vw ON (vw.pass_id = ps.pass_id) WHERE rb.booking_id = rbg.booking_id ) WHERE rbg.host_id IS NULL; Executing it, gives me following error:
Error Code: 1093. You can't specify target table 'rbg' for update in FROM clause
How can be this query be rewritten, so it will work?