日期:2014-05-20 浏览次数:20799 次
mysql> CREATE TRIGGER tr_newtable_bi BEFORE INSERT ON newtable -> FOR EACH ROW -> set new.bb=case new.aa when 3 then 5 when 2 then 10 else new.bb end; Query OK, 0 rows affected (0.17 sec) mysql> insert into newtable values (1,2,3),(2,3,4),(3,6,9); Query OK, 3 rows affected (0.04 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select * from newtable; +------+------+------+ | id | aa | bb | +------+------+------+ | 1 | 2 | 10 | | 2 | 3 | 5 | | 3 | 6 | 9 | +------+------+------+ 3 rows in set (0.00 sec) mysql>