天天看點

MySQL 關聯多表查詢更新例子 & from LOW B

update change_request cr
inner join application app on cr.app_name = app.app_name
inner join aone_product p on p.aone_product_id = app.aone_product_id
inner join department d on d.dept_no = p.dept_no
set
cr.dept_no  = p.dept_no,
cr.dept_name = d.dept_name
where cr.cr_id in (select cr.cr_id from (select * from change_request) cr) and p.dept_no is not null

           

其中,MySQL中有個很LOW的from問題,你需要這樣寫:

update request_resource set method = 'X' where id in (SELECT rr.id FROM (select * from request_resource) rr where rr.id < 30);
           

是不是感覺有點LOW ?

(SELECT rr.id FROM (select * from request_resource)
           

新版本中,應該改善了。

繼續閱讀