how to write mysql trigger

前端 未结 2 410
我在风中等你
我在风中等你 2021-01-15 03:15


there are two tables
table A

if user use this query \"insert into A values(abc,1,50);\"

then trigger should check student_nam

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-15 03:30

    try like this...

    if (Select Count(Name) from B where B.Name=new.name)<1 
    insert into summary_score (name,number,all_marks)
    values(new.name,new.marks,new.score);
    else 
    update B set all_marks=old.all_marks+new.student_marks where B.Name=new.Name;
    

提交回复
热议问题