我试着就判断yw成绩的档次,并填写到ywdc中,就以下的一段程序 create procedure syzx.student_getGrade (biaozhi char(6)) BEGIN declare ywdc_grade char; select ywdc into ywdc_grade from cj_finish where biaozhi=biaozhi; if ywdc_grade>=120 then select ywdc_grade,'A'; elseif ywdc_grade<120 and ywdc_grade>=110 then select ywdc_grade,'B'; elseif ywdc_grade<110 and ywdc_grade>=100 then select ywdc_grade,'C'; else select ywdc_grade,'D'; end if; END 但是没有反应,请问如何修改。谢谢
最简单的思路就是如下。update cj_finish set ywdc=case when yw>=120 then 'A' when yw>=110 then 'B' when yw>=100 then 'C' else 'D' end, sxdc=case when sx>=120 then 'A' when sx>=110 then 'B' when sx>=100 then 'C' else 'D' end, yydc=case when yy>=120 then 'A' when yy>=110 then 'B' when yy>=100 then 'C' else 'D' end
或者复杂一点儿的如下。 update cj_finish set ywdc=etl(interval(yw,0,100,110,120),'D','C','B','A'), sxdc=etl(interval(sx,0,100,110,120),'D','C','B','A'), yydc=etl(interval(yy,0,100,110,120),'D','C','B','A');
create procedure syzx.student_getGrade
(biaozhi char(6))
BEGIN
declare ywdc_grade char;
select ywdc into ywdc_grade from cj_finish where biaozhi=biaozhi;
if ywdc_grade>=120 then
select ywdc_grade,'A';
elseif ywdc_grade<120 and ywdc_grade>=110 then
select ywdc_grade,'B';
elseif ywdc_grade<110 and ywdc_grade>=100 then
select ywdc_grade,'C';
else
select ywdc_grade,'D';
end if;
END
但是没有反应,请问如何修改。谢谢
set ywdc=case when yw>=120 then 'A' when yw>=110 then 'B' when yw>=100 then 'C' else 'D' end,
sxdc=case when sx>=120 then 'A' when sx>=110 then 'B' when sx>=100 then 'C' else 'D' end,
yydc=case when yy>=120 then 'A' when yy>=110 then 'B' when yy>=100 then 'C' else 'D' end
update cj_finish
set ywdc=etl(interval(yw,0,100,110,120),'D','C','B','A'),
sxdc=etl(interval(sx,0,100,110,120),'D','C','B','A'),
yydc=etl(interval(yy,0,100,110,120),'D','C','B','A');
$yw = xx;
$sx = xx;
$yy = xx;//接收传入的档值并赋值,xx为传入的档值
$a = xx;
$b = xx;
$c = xx; //小于c的都是d//语文比较
if ($yw > $a){
$ywdc = 'a';
}elseif ($yw > $b){
$ywdc = 'b';
}elseif ($yw > $c){
$ywdc = 'c';
}else {
$ywdc = 'd';
}//数学比较
if ($sx > $a){
$sxdc = 'a';
}elseif ($sx > $b){
$sxdc = 'b';
}elseif ($sx > $c){
$sxdc = 'c';
}else {
$sxdc = 'd';
}//英文比较
if ($yy > $a){
$yydc = 'a';
}elseif ($yy > $b){
$yydc = 'b';
}elseif ($yw > $c){
$yydc = 'c';
}else {
$yydc = 'd';
}$str = "insert into cj_finish values($yw,$ywdc,$sx,$sxdc,$yy,$yydc)";
这样不就可以了吗?
谢谢您,我是新手,暂时还不会用PHP,我现在用navicat来操作mysql,正在准备找什么样的应用程序来学习,虽然上面的程序还看不懂,但是您给了我一个想要的东西,那就是我学了mysql后下一步我需要学什么。