合并 MySQL 语句:更新 CommunicationProfile 表
可以合并为以下一句 MySQL 语句:
UPDATE CommunicationProfile SET
contacts = contacts + IF(username = NEW.contact OR username = NEW.username, 1, 0),
contactrequests = contactrequests - IF(contactrequests > 0 AND username = NEW.username, 1, 0),
contactrequested = contactrequested - IF(contactrequested > 0 AND username = NEW.contact, 1, 0)
WHERE username IN (NEW.username, NEW.contact);
原文地址: https://www.cveoy.top/t/topic/mZWj 著作权归作者所有。请勿转载和采集!