1

「別のテーブルからレコードを更新する」など、これに似た質問がたくさんありますが、これを機能させることができませんでした。

テーブルを選択して更新するクエリがありますsem_stdexamfinresmark。selectサブクエリは、更新中のテーブルとサイズが等しくない可能性のあるデータの複数の行を返しますが、更新は現在機能しています。

クエリは次のようになります。

update  sem_stdexamfinresmark sr,
    (select 
         se.currsession,
         str.studentid,
         str.classid,
         str.subjectid,
         str.aggScore*(select gbtp.percentage from gb_termpercentage gbtp where gbtp.termname = se.examtype)/100 as aggPer,
         str.aggGrade
    from 
        sem_stdexamtermresr str,
        sem_exam se 
    where 
        str.examid=se.examid and 
        se.examtype = 'Second Term' and
        se.currsession =1 and classid='8' 
     ) s
     set 
        sr.SecondTermMark = s.aggPer and
        sr.SecondTermGrade = s.aggGrade 
     where
        sr.studentid=s.studentid and 
        sr.subjectid=s.subjectid and 
        s.currsession = s.currsession and
        sr.classid='8';

編集:

update  sem_stdexamfinresmark 
 set 
    sr.SecondTermMark = s.aggPer and
    sr.SecondTermGrade = s.aggGrade 
from 
(select 
     se.currsession,
     str.studentid,
     str.classid,
     str.subjectid,
     str.aggScore*(select gbtp.percentage from gb_termpercentage gbtp where gbtp.termname = se.examtype)/100 as aggPer,
     str.aggGrade
from 
    sem_stdexamtermresr str,
    sem_exam se 
where 
    str.examid=se.examid and 
    se.examtype = 'Second Term' and
    se.currsession = 1 and classid='8' 
 ) s
 where
    sr.studentid=s.studentid and 
    sr.subjectid=s.subjectid and 
    s.currsession =1 and
    sr.classid='8';
    select * from sem_exam;
    update sem_exam set currsession =1;
4

2 に答える 2

0

次のようなものを試してください。

update foo
set col = bar.col
from bar
where ...
于 2011-06-20T08:36:35.233 に答える
0

これは、人が眠りを失ったときに起こることです:(私はここでばかげた間違いをして、「そして」を追加しました

于 2011-06-23T07:37:36.353 に答える