本文介绍了仅当字符串的最后一个单词与字母匹配时才更新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当(HostCd)列的姓与字符串的最后一个单词匹配时,我想更新列(HostActvTyp和HostPrvTyp)主机列"NXVR"的示例字符串,"REACTIVE",所以最后一个单词是R,因此当N'为"NEW"时,我们必须更新为Reactive示例"XVDN"在此处输入图片描述
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
推荐答案
https://www.db-fiddle.com/f/bG4jZfnWksjc315eGTuG2k/1
UPDATE tablename
SET ActTyp = 'INDEPENDENT'
WHERE 'I' = RIGHT(ActvTyp, 1)
或者是否有空格分隔符
UPDATE tablename
SET ActTyp = 'INDEPENDENT'
WHERE ' I' = RIGHT(ActvTyp, 2)
这篇关于仅当字符串的最后一个单词与字母匹配时才更新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!