在具有多个IF/CASE条件的SQLite UPDATE触发器中
在触发器中如何获取多个条件检查LIKE
CREATE TRIGGER record_big_order AFTER INSERT ON orders
BEGIN
IF new.value > 1000000 THEN
INSERT INTO big_orders (customer_name, salesman_id, value,Mark)
VALUES (new.customer_name, new.salesman_id, new.value,'1')
END IF;
IF new.value > 2000000 THEN
INSERT INTO big_orders (customer_name, salesman_id, value,Mark)
VALUES (new.customer_name, new.salesman_id, new.value,'2')
END IF;
IF new.value > 3000000 THEN
INSERT INTO big_orders (customer_name, salesman_id, value,Mark)
VALUES (new.customer_name, new.salesman_id, new.value,'3')
END IF;
END;
解决方案
您可以尝试下面的INSERT语句-
INSERT INTO big_orders (customer_name, salesman_id, value,Mark)
VALUES (new.customer_name, new.salesman_id, new.value,
CASE WHEN new.value > 3000000 THEN '3'
WHEN new.value > 2000000 THEN '2'
WHEN new.value > 1000000 THEN '1' END)
相关文章