2015年8月12日 星期三

update select查詢後的資料

原來Update跟Select也可以這麼麻吉,太厲害了。
解決10年前grad_stud資料表畢業生的流水號被誤刪的情形。

update `grad_stud` as A,
(select student_sn,stud_id from stud_seme  WHERE seme_year_seme = 0932 and seme_class LIKE '9%') as B
set A.`student_sn`= B.`student_sn`
where A.`stud_grad_year`= 93 and A.`stud_id`=B.`stud_id`;

沒有留言:

張貼留言