本文目录一览:
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/n/272309.html