具有多个值的Mysql触发器

时间:2014-12-17 01:53:22

标签: mysql triggers

如何在一个触发器中对用户名值执行相同操作?

由于

DELIMITER //
  CREATE TRIGGER notnullnameandsurname BEFORE INSERT ON guests FOR EACH ROW
  BEGIN
  IF new.name = "" then
  SIGNAL SQLSTATE '45000';
  END IF;
  END //

1 个答案:

答案 0 :(得分:1)

如何使用or

DELIMITER //
  CREATE TRIGGER notnullnameandsurname BEFORE INSERT ON guests FOR EACH ROW
  BEGIN
  IF new.name = '' or new.username = '' then
  SIGNAL SQLSTATE '45000';
  END IF;
  END //