I want to update columns(HostActvTyp and HostPrvTyp) when (HostCd) column last name is matching with last word of the string is "R" example string for host column "NXVR','REACTIVE', so the last word is R so we have to update to Reactive when it's N' to 'NEW' example "XVDN" enter image description here
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
seems you are looking for left or substr()
update tablename
set ActTyp = 'INDEPENDENT'
where ActvTyp = left(your_value,1 )
回答2:
https://www.db-fiddle.com/f/bG4jZfnWksjc315eGTuG2k/1
UPDATE tablename
SET ActTyp = 'INDEPENDENT'
WHERE 'I' = RIGHT(ActvTyp, 1)
Or if there is a space separator
UPDATE tablename
SET ActTyp = 'INDEPENDENT'
WHERE ' I' = RIGHT(ActvTyp, 2)