简体   繁体   中英

Oracle Update Table from Query Results (Not From Another Table)

I have the following query results:

orclid13 | casenm | (adultfn||''||adultln)

123      |12345   | jane doe
124      |45645   | john doe
etc..

I have another table called Cases with the following columns:

casenm | matter_name

I want to copy the names from the (adultfn||''||adultln) results column and populate it in the matter_name column in the Cases table and have it be joined by casenm and look like this.

casenm | matter_name

95522  |
74555  |
12345  | jane doe
45645  | john doe

One method is a correlated subquery:

update cases 
    set matter_name = (select col3
                       from (<your query here>) q
                       where q.casenm = cases.casenm
                      );

Note that this will set non-matching values to null , which seems consistent with your question.

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