sql更新,字典值轉換,

2021-09-24 13:33:11 字數 622 閱讀 4595

update population set education_degree = (case 

when education_degree='博士' then 0

when education_degree='研究生' then 1

when education_degree='本科' then 2

when education_degree='大專' then 3

when education_degree='中專或中技' then 4

when education_degree='技工學校' then 5

when education_degree='高中' then 6

when education_degree='初中' then 7

when education_degree='小學' then 8

when education_degree='文盲或半文盲' then 9

when education_degree='其他' then 99 end )

where education_degree in ('博士','研究生','本科','大專','中專或中技','技工學校','高中','初中','小學','文盲或半文盲','其他')

更新欄位的sql

update pro traininfo t set t.totalmoney select a.price t.totaltime from gen makepriceinfo a where a.studentcode t.studentcode and a.examcode t.examcod...

資料插入之前更新字段值

在乙個表報警資訊中插入記錄,但是沒有x,y值資訊,其中的x,y值要根據記錄中的現場警力編號到gps警員表中查取xy值,然後付給當前記錄,再進行插入。create or replace trigger getxy before insert on sdga.報警資訊 for each row decl...

通過sql批量更新字段內容

1.也許現在大家都不需要寫sql了,鑑於我技術比較落後,加上開發的系統還有在使用,所以還是有業務需要用到。2.伺服器搬家,導致資料庫裡,伺服器的路徑發生改變,所以要批量替換。設定網域名稱就不用管這個坑 檢索出要替換的內容條數 select count from shop item where pho...