Oracle同時更新兩記錄

2021-07-12 02:58:27 字數 573 閱讀 6431

t_check表結構,該錶主鍵為(w_id+rw_num)

要變更的記錄:

業務目標為同時修改這兩條記錄的opinion欄位:當用operator為sup時將opinion改為'超級管理員',當operator為其他值是將opinion修改為'普通管理員'。

最終處理方法使用了case-when,sql如下:

update t_check_test set check_time='094012',opinion=case operator when 'sup' then replace(opinion,opinion,'超級管理員')

when '067337' then replace(opinion,opinion,'普通管理員')

endwhere rw_id='aqbw000292' and rw_num ='0000' and operator in ('067337','sup')

ORACLE 新增記錄 更新記錄

開發中偶爾需要新增一條記錄或修改一條記錄的幾個字段,語法中有微妙的區別。由於不是經常寫,久不寫就忘記了,而又要重新查詢或除錯。新增記錄語法 新增記錄 仿照已有表記錄 insert into t x t t.field 1,t.field 2,t.field 3,t.field 4,t.field 5...

Mysql計算相鄰兩兩記錄某個欄位的最大差值

需求乙個患者有多條病程記錄,查詢該患者的 最大檢查間隔。即求兩兩記錄的最大檢查間隔 天數 注1 其中檢查時間是 case record表中的create time欄位,其中user id是患者編號。注2 下文的 符號是mysql的 變數標識。select rownum 0就是把0賦值給rownum變...

Oracle 記錄 持續更新

1 select distinct area.region code from tb organization org inner join tb admindivision area on org.area code area.region code 2 select distinct area....