简体   繁体   中英

Update statement in Mysql and Oracle

I have an update statement that is working in Mysql.(update multiple records, based on the column in another table)

UPDATE  `table1` m 
INNER JOIN
(SELECT cse_cd FROM  table2 WHERE clsf_ind='NC') t 
ON m.cse_cd = t.cse_cd 
SET m.ST_CD = 'QUEST03'

However, it does not work in Oracle. Can somebody help on this.

This should do the job:

UPDATE table1 
SET ST_CD = 'QUEST03'
WHERE EXISTS 
     (SELECT 1 
      FROM table2 
      WHERE clsf_ind='NC' AND table1.cse_cd=table2.cse_cd); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM