Oracle將一張表幾個字段賦值到另一張表指定字段

2021-09-19 03:40:05 字數 557 閱讀 2547

由於某種原因客戶資料庫中 trp_advp表部分記錄的projectname和groupname兩個字段值丟失,由於trp_reportitem 表中可以找到對應的資料,於是通過該錶進行資料還原.trp_advp中一條記錄對應trp_reportitem中的多條記錄,因此需要對trp_reportitem分組查詢,賦值的條件為trp_advp.id=trp_reportitem.advp_id

注意:trp_advp和結果集item的記錄數要相同

update trp_advp set(trp_advp.projectname,trp_advp.groupname)=(

select item.project_name,item.group_name

from (

select advp_id,group_name,project_name from trp_reportitem group by advp_id,group_name,project_name

) item where trp_advp.id=item.advp_id

)

Oracle一張表的多個字段更新到另一張表中去

假設表a中有多個字段 province city 需要從b表獲取 兩張表的mobile一樣 總結了幾種寫法。一 update a set a.province select province from b where b.mobile a.mobile update a set a.city sel...

oracle中一張表的某個欄位與另一張表關聯

今天在無意間查詢到乙個sql,有兩張表,一張使用者表,使用者表中有個personroles欄位,clob型別,裡面是逗號分隔的角色id a,b,c,d 需要查詢每個人和其現有的角色。問題在於使用者表和角色表的關聯,直接left join用roles.id in user.personroles 查詢...

將一張表的資料插入另外一張表

表cmb send sms create table cmb send sms send id bigint 20 not null auto increment comment 主鍵id phone no varchar 32 not null comment 手機號碼 status varcha...