初学者求助

zhuy82 2018-07-28 05:25:37
如何利用存储对班级考生,考试成绩59分,自动加1分
...全文
590 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
叶落千尘 2018-09-19
  • 打赏
  • 举报
回复
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;
玛棋朵 2018-09-18
  • 打赏
  • 举报
回复
update 表名 set 成绩字段名 = 60 where 成绩字段名 = 59
verejava 2018-08-31
  • 打赏
  • 举报
回复
ETJojo 2018-08-29
  • 打赏
  • 举报
回复
新手进来学习一下。一楼标准答案。
VictorJon 2018-08-08
  • 打赏
  • 举报
回复
回这么认真 , 人家都不带结贴的
  • 打赏
  • 举报
回复
update tbname set 成绩=成绩+1 where 成绩=59 and 班级=‘满足条件的班级’
如果成绩表中没有直接的班级字段,那么可以这样:
update tbname set 成绩=成绩+1 where 成绩=59 and exists(select 班级 from 学生表 where 学生表.学生号=成绩表.学生号 and 学生表.班级=‘满足条件的班级’)
VictorJon 2018-08-06
  • 打赏
  • 举报
回复
update 表名 set 成绩字段名 = 60 where 成绩字段名 = 59
油炸小波 2018-07-30
  • 打赏
  • 举报
回复
create proc Queryscore
(
@Switch int,
@name varchar(50)
)
as
if @Switch=59
--最高分数
begin
update table set score = 60 where name=@name
end

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧