数据库 mysql 
比如 一个表 名字叫 tb_main
里面有两个字段 一个 dj (单价) 一个 qbje (全部金额)
如果 dj 有变化了,qbje 就要对应的 加上 dj   这个该怎么写。
主要是格式 不会。麻烦了

解决方案 »

  1.   

    可能意思没表达清楚
    我想问的就是最最基本的一个表 名字叫 tb_cc
    里面有两个字段 一个 aa  一个  bb
    想把aa 的值 赋给 bb  该 怎么写
      

  2.   


    楼主是想实现功能  还是  目的在触发器mysql> DELIMITER |
    mysql> create trigger set_record after insert on score
        -> for each row begin
        -> set @studentid=new.student_id;
        -> set @record=new.record;
        -> set @score=new.score;
        -> if @score>85 then
        -> update score set score.record=5 where student_id=@studentid;
        -> else if @score>70 then
        -> update score set sc.record=4 where student_id=@studentid;
        -> else if @score>60 then
        -> update score set score.record=3 where student_id=@studentid;
        -> else
        -> update score set score.record=0 where student_id=@studentid;
        -> end if;
        -> end;
        -> |