求一条数据库SQL更新语句

表t_fpbh中
S200871700016(00076501),S2008072200032 (00077476),S2008072300020(00077770)
这3个号出现重复.括号中是对应的条件
我想把他们3个号分别修改成S200871701016,S2008072201032,S2008072301020
我要写3个语句,有点麻烦,可以不可以把3个语句合成一个语句?
update t_fpbh
set fpbh='s2008071701016'
where swbh=00076501 and fpbh='s2008071700016'

update t_fpbh
set fpbh='s2008072201032'
where fpbh='s2008072200032' and swbh=00077476

update t_fpbh
set fpbh='s2008072301020'
where swbh=00077770 and fpbh='s2008072300020'
后面两位兄弟的都不对
都有点问题
最新回答
枫以

2022-10-29 15:33:52

update语句只能针对条件满足的!

你那些条件如果写到一起的话

那么满足条件的行数为0.

所以是不能实现滴!
我迁就她的任性

2024-01-08 23:13:53

用字符串截取呀:
UPDATE t_fpbh SET fpbh = SUBSTRING(fpbh, 1, 10) + '10' + RIGHT(RTRIM(fpbh), 2) WHERE swbh IN ('00077770', '00077476', '00076501')

搞定,嘿嘿,至少你上面的要求能达到
小承诺≈′

2020-07-17 12:23:37

没有吧,我是不知道,帮不上你了,共同关注这个问题吧
往事輕如煙

2020-08-01 00:39:15

update t_fpbh
set fpbh=(case when swbh=00076501 and fpbh='s2008071700016' then 's2008071701016'
when fpbh='s2008072200032' and swbh=00077476
then 's2008072201032'
when swbh=00077770 and fpbh='s2008072300020'
then 's2008072301020' )
where swbh=00076501 and fpbh='s2008071700016' or
(fpbh='s2008072200032' and swbh=00077476 ) or
(swbh=00077770 and fpbh='s2008072300020')
泽城美雪

2023-02-19 23:43:50

update t_fpbh
set fpbh=case when swbh=00076501 and fpbh='s2008071700016' then 's2008071701016'
when fpbh='s2008072200032' and swbh=00077476
then 's2008072201032'
when swbh=00077770 and fpbh='s2008072300020'
then 's2008072301020' end