*注意:我不想将B和D更新为欺诈者。它们只是欺诈用户的共享属性。因此,如果我决定将用户A更改为欺诈者。与其他用户没有任何变化。
答案 0 :(得分:2)
说实话,问题是非常抽象的,因此需要做出如下一些假设,
MobileNo OR DeviceId OR EmailId OR IPAddress
的重复决定了老派。所以回答您的问题,
AfterUpdate
上创建一个table
触发器。Fetch
和Update
中,对MobileNo
OR DeviceId
OR 具有重复值的行EmailId
OR IPAddress
。仅在NEW.IsFraudsterStatus = 1
,
if (NEW.IsFraudsterStatus = 1) THEN
UPDATE tableUser
SET IsFraudsterStatus = 1
WHERE
(tableUser.MobileNo = NEW.MobileNo
OR
tableUser.DeviceId = NEW.DeviceId
OR
tableUser.EmailId = NEW.EmailId
OR
tableUser.IPAddress = NEW.IPAddress)
AND
IsFraudsterStatus = 0;
ELSE
UPDATE tableUser
SET IsFraudsterStatus = 0
WHERE
(tableUser.MobileNo = NEW.MobileNo
OR
tableUser.DeviceId = NEW.DeviceId
OR
tableUser.EmailId = NEW.EmailId
OR
tableUser.IPAddress = NEW.IPAddress)
AND
IsFraudsterStatus = 1;
END IF;
在上面的查询中,您可以添加所需的conditions
,请注意OR
,以便在任何条件为真的情况下使帐户成为欺诈者。
AND
ed条件,它将防止无限递归触发。此外,我还建议使用BeforeInsert
触发器,该触发器将验证并限制欺诈者帐户的创建。