代码如下:
CREATE TRIGGER inserisci_richiesta_noID AFTER INSERT ON Richiesta
FOR EACH ROW
BEGIN
IF (NEW.ID_Cliente == NULL AND (NEW.Email NOT IN (SELECT Email FROM Utente))) THEN
INSERT INTO Utente(ID, Nome, Cognome, Email, Telefono, ID_Livello_accesso)
VALUES (NULL, 'Generato', 'Automaticamnete', NEW.Email, NEW.Telefono, 1);
UPDATE Richiesta
SET ID_Cliente = (SELECT ID FROM Cliente WHERE Email = :NEW.Email);
ELSE NEW.ID_Cliente == NULL AND NEW.Email IN (SELECT Email FROM Utente;) THEN
UPDATE Richiesta
SET ID_Cliente = (SELECT ID FROM Cliente WHERE Email = NEW.Email);
END IF;
END;
它给了我这个错误:
1064-您的sql语法有错误;请检查与您的mysql服务器版本对应的手册,以获得正确的语法,以便在“==null”附近使用(new.email not in(select email from utente)),然后在第4行的u'中插入
1条答案
按热度按时间zyfwsgd61#
这是密码