我有三张桌子。
members
它有一个可以为空的列,称为blocked
,ID
和primaryPhone
。blockedinfo
它有 2 列info
和type
.phoneNumbers
它有ID
,prefix
,phoneNumber
,memberID
当我在成员表中设置阻止字段时,我正在尝试在members
表上创建一个触发器以将用户主要电话号码插入表中。blockedinfo
并从blockedinfo
我将blocked
字段设置为NULL
CREATE TRIGGER `members.before_update` BEFORE UPDATE ON `members` FOR EACH ROW BEGIN
IF( NEW.`blocked` IS NOT NULL ) THEN
INSERT INTO `blockedinfo` ( phone, 'userPhoneNumberValue')
SELECT CONCAT( `prefix` , `phoneNumber` ) AS 'phone'
FROM `phonenumbers`
WHERE `ID` = NEW.`primaryPhone`
AND `memberID` = NEW.`ID`
LIMIT 1 ;
ELSE
DELETE FROM `blockedinfo` WHERE `info` IN (
SELECT CONCAT( `prefix` , `phoneNumber` )
FROM `phonenumbers`
WHERE `ID` = NEW.`primaryPhone`
AND `memberID` = NEW.`ID`);
END IF ;
END ;
尝试构建触发器时出现此错误
以下查询失败:“CREATE DEFINER= root
@ 127.0.0.1
TRIGGER members.before_update
BEFORE UPDATE ON members
FOR EACH ROW BEGIN MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''phoneNumberValue') SELECT CONCAT(
prefix ,
phoneNumber`) AS 'phone' at line 4