我收到ERROR 1205(HY000):超出锁定等待超时;在查询下面的语句时尝试重新启动事务。
此查询的想法是更新“Realm”表上的值列...但我需要的信息位于另一个表(enterprise_feature链接到企业)中。另外,我有一个条件(where子句),只能在'user'表中找到。
有人可以帮我弄清楚我在这里缺少什么吗?我真的很感激。
UPDATE realm r
LEFT JOIN user u ON u.id = r.owner_id
LEFT JOIN enterprise e ON e.id = r.pricing_plan_id
LEFT JOIN enterprise_feature ef ON ef.enterprise_id = e.id
LEFT JOIN (SELECT enterprise_id, SUM(feature_flag_id) "A"
FROM enterprise_feature ef) x ON e.id = x.enterprise_id
SET r.feature_flags =
CASE
WHEN r.feature_flags <> -1 THEN r.feature_flags+67108864
WHEN r.feature_flags = -1 THEN x.A+67108864
END
, r.updated_at = SYSDATE()
WHERE r.pricing_plan_id = '161' AND u.premium_support = '1' AND r.deleted = 0;