update PosInStore set
CodePosOne=case
when CodePosOne=1-- then A --成都
when CodePosOne=2-- then B --重庆
我要更改分类表,第一级分类字段CodePosOne,第二级分类CodePosTwo,当找到1时,同时更改CodePosOne和CodePosTwo的值。
如何改写上面sql。上面那段只能改第一级CodePosOne的值。
CodePosOne=case
when CodePosOne=1-- then A --成都
when CodePosOne=2-- then B --重庆
我要更改分类表,第一级分类字段CodePosOne,第二级分类CodePosTwo,当找到1时,同时更改CodePosOne和CodePosTwo的值。
如何改写上面sql。上面那段只能改第一级CodePosOne的值。
类似这样,但我想一条sql解决,像下面那种,就可以一次改多个分类
update PosInStore set
CodePosOne=case
when CodePosOne='01--' then '01' --成都
when CodePosOne='02--' then '01' --重庆
when CodePosOne='03--' then '01' --上海
end
insert into @t1 (col1, col2)
select '01', '0000000000'
union
select '02', '0000000000'
union
select '03', '0000000000'
union
select '04', '0000000000'select * from @t1update @t1 set col1 = case when col1 = '01' then '成都'
when col1 = '02' then '重庆'
when col1 = '03' then '上海'
when col1 = '04' then '纽约'
end,
col2 = case when col1 = '01' then '中国'
when col1 = '02' then '中国'
when col1 = '03' then '中国'
when col1 = '04' then '美国'
end
select * from @t1