求一条数据库SQL更新语句
发布网友
发布时间:2024-10-06 15:56
我来回答
共5个回答
热心网友
时间:2024-11-12 00:54
update语句只能针对条件满足的!
你那些条件如果写到一起的话
那么满足条件的行数为0.
所以是不能实现滴!
热心网友
时间:2024-11-12 00:55
用字符串截取呀:
UPDATE t_fpbh SET fpbh = SUBSTRING(fpbh, 1, 10) + '10' + RIGHT(RTRIM(fpbh), 2) WHERE swbh IN ('00077770', '00077476', '00076501')
搞定,嘿嘿,至少你上面的要求能达到
热心网友
时间:2024-11-12 00:55
没有吧,我是不知道,帮不上你了,共同关注这个问题吧
热心网友
时间:2024-11-12 00:56
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')
热心网友
时间:2024-11-12 00:57
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