create proc Queryscore ( @Switch int, @name varchar(50) ) as if @Switch=59 --最高分数 begin update table set score = 60 where name=@name end
update 表名 set 成绩字段名 = 60 where 成绩字段名 = 59
update tbname set 成绩=成绩+1 where 成绩=59 and 班级=‘满足条件的班级’ 如果成绩表中没有直接的班级字段,那么可以这样: update tbname set 成绩=成绩+1 where 成绩=59 and exists(select 班级 from 学生表 where 学生表.学生号=成绩表.学生号 and 学生表.班级=‘满足条件的班级’)
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;
(
@Switch int,
@name varchar(50)
)
as
if @Switch=59
--最高分数
begin
update table set score = 60 where name=@name
end
如果成绩表中没有直接的班级字段,那么可以这样:
update tbname set 成绩=成绩+1 where 成绩=59 and exists(select 班级 from 学生表 where 学生表.学生号=成绩表.学生号 and 学生表.班级=‘满足条件的班级’)
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;