Mysql-触发器

用触发器实现2个表字段值的同步更新
drop trigger if exists tgr_example;
create trigger test.tgr_example
    before update
    on test.table1
    for each row
begin
    if OLD.views_count < NEW.views_count then
        update test.table2 a set a.views_count = a.views_count + 1 where a.series_id = old.series_id;
    end if;
end;

你可能感兴趣的:(Mysql,mysql,触发器)