当我尝试更新表中的值并进行更新后,触发器会自动触发,因为出现错误ERROR 1093:1093:您无法指定目标表'uim',因此我无法进行更新在FROM子句中进行更新。
有人可以帮我吗?
UPDATE user_institution uim
INNER JOIN
user_master um ON uim.user_id = um.id
SET
uim.status = '1'
WHERE
uim.institution_id = NEW.id
AND (um.country_id = NEW.country_id
|| um.country_id IN (SELECT
icm.country_id
FROM
institution_country_mapping icm
WHERE
icm.institution_id = NEW.id
AND icm.status = '1'))
AND NOT EXISTS( SELECT
tb.user_id
FROM
(SELECT
uim2.user_id
FROM
user_institution uim2
INNER JOIN institution_master im ON uim2.institution_id = im.id
WHERE
uim2.user_id = um.id
AND im.is_default = '2'
AND uim2.status = '1'
AND im.status = '1') AS tb);