Oracle SQL: Update a table with data from another table

后端 未结 7 2142
广开言路
广开言路 2020-11-22 02:01

Table 1:

id    name    desc
-----------------------
1     a       abc
2     b       def
3     c       adf

Table 2:

id    na         


        
7条回答
  •  名媛妹妹
    2020-11-22 02:35

    Here seems to be an even better answer with 'in' clause that allows for multiple keys for the join:

    update fp_active set STATE='E', 
       LAST_DATE_MAJ = sysdate where (client,code) in (select (client,code) from fp_detail
      where valid = 1) ...
    

    The beef is in having the columns that you want to use as the key in parentheses in the where clause before 'in' and have the select statement with the same column names in parentheses. where (column1,column2) in ( select (column1,column2) from table where "the set I want" );

提交回复
热议问题