如何利用存储对班级考生,考试成绩59分,自动加1分

解决方案 »

  1.   

    create proc Queryscore
    (
    @Switch int,
    @name varchar(50)
    )
    as
    if @Switch=59
    --最高分数
    begin
    update table set score = 60 where name=@name
    end
      

  2.   

    update 表名 set 成绩字段名 = 60 where 成绩字段名 = 59 
      

  3.   

    update tbname set 成绩=成绩+1 where 成绩=59 and 班级=‘满足条件的班级’
    如果成绩表中没有直接的班级字段,那么可以这样:
    update tbname set 成绩=成绩+1 where 成绩=59 and exists(select 班级 from 学生表 where 学生表.学生号=成绩表.学生号 and 学生表.班级=‘满足条件的班级’)
      

  4.   

    MySql DDL DML基本命令http://www.verejava.com/?id=1717411998521
      

  5.   

    update 表名 set 成绩字段名 = 60 where 成绩字段名 = 59 
      

  6.   

    DELIMITER //
    create procedure add_count(in idx int,in sum int)          --传入两个参数,一个为学生的ID,一个为成绩
    begin
    declare sum1 int;
    if sum = 59 then                     --如果分数为59,那么加1
        set sum1 = sum + 1;
        update tb_name set 成绩 = sum1 where id = idx;
    end fi;
    end //
    DELIMITER ;
    或者更新语句可以直接写成update tb_name set 成绩 = 60 where id = idx;