本文目錄一覽:
sql 多表關聯欄位互相替換 值更新
update T_HPP_MonthVariableHourBill
set FControlUnitID =
(
select son.FHRORGUNITID
from T_HR_FluctuationBillEntry as ftry
left outer join T_BD_Person as son on ftry.FPERSONID=son.fid
left outer join T_HPB_AttendanceArchives as ves on son.fid=ves.fpersonid
left outer join T_HPP_MonthVariableHourBill AS bill on ves.fid=bill.fattarchid
where son.FHRORGUNITIDbill.FControlUnitID and ves.fid =’tTAUp9mAS+KGqhBpFUSO+eaBfXk=’
)
where FControlUnitID in
(
select bill.FControlUnitID
from T_HR_FluctuationBillEntry as ftry
left outer join T_BD_Person as son on ftry.FPERSONID=son.fid
left outer join T_HPB_AttendanceArchives as ves on son.fid=ves.fpersonid
left outer join T_HPP_MonthVariableHourBill AS bill on ves.fid=bill.fattarchid
where son.FHRORGUNITIDbill.FControlUnitID and ves.fid =’tTAUp9mAS+KGqhBpFUSO+eaBfXk=’
)
;
如何對sql資料庫中的某一欄位進行替換?
1.SQL欄位名稱替換,可以用AS。
如:select ID,NAME as 姓名 from table
2.替換某欄位某些行的值可以用update。
如:update table set Name=’zhang san’ where name=’條件表達式’
3.列值替換還有replace函數。
答案:update 表名 set 列1=’yr’ where 列1=’hr’
repalce(要置換的欄位,需要替代的字元,替換後的字元)
update 表名 set 列1=replace(列1,’hr’,’yr’);
SQL 2008 批量替換更新
語句:
update [tablename] set XH = substring(XH,0,charindex(‘/’,XH,1)) + ‘M’ + substring(XH,charindex(‘/’,XH,1)+1,len(XH))
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/272309.html