*Note: I do not want to Update B and D to be a fraudster. they are just shared attributes with fraud users. So If I decided to change user A to be not a fraudster. No changes with the other users.
To be honest Question is pretty abstract, so need to make few assumptions as follows,
MobileNo OR DeviceId OR EmailId OR IPAddress
decides fradster.So to answer your question,
AfterUpdate
trigger on your table
.Fetch
and Update
rows those having duplicate value for either MobileNo
OR DeviceId
OR EmailId
OR IPAddress
.Fire Update query only if, 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;
In above query you may add as much as conditions
you need, please note by OR
ing them so that account is fraudster if any of the condition is true.
AND
ed condition it will prevent endless recursive triggering.And besides this I would recommend a BeforeInsert
trigger, that will validate and restrict fraudster account getting created.