好的..这可能看起来很奇怪,但是有没有办法在 if 语句的多个条件中找到满足哪个条件?我正在 MySql 5.1 中编写触发器,我必须在某些条件下引发错误。我想做一些类似下面的代码,
if(new.col1 = 'A' and (new.col2 is null or new.col3 is null) {
//if new.col1 = 'A' and **new.col2** was null
set msg = '<col2> cannot be null';
}
if(new.col1 = 'B' and (new.col4 is null or new.col5 is null) {
//if new.col1 = 'B'and **new.col5** was null
set msg = '<col5> cannot be null';
}
如果我对此有任何解决方案,那么我将节省 1000 次if
循环!!!