日期:2014-05-18  浏览次数:20537 次

SQL列值修改
表aaaa
shapecode shapename
11 常温
12 低温
13 冰冻
变成
shapecode shapename
11 箱子(常温)
12 箱子(低温)
13 箱子(冰冻)
11 盒子(常温)
12 盒子(低温)
13 盒子(冰冻)

------解决方案--------------------
create table tm(shapecode int ,shapename varchar(20))
insert into tm select 11,'常温'
insert into tm select 12,'低温'
insert into tm select 13,'冰冻'

select shapecode ,'箱子('+shapename +')' as shapename from tm 
union
select shapecode ,'盒子('+shapename +')' as shapename from tm 




------解决方案--------------------

select t1.shapecode, t.col+'('+t1.shapename+')' 
from 
(select '盒子' as col
union all
select '箱子')t
cross join
aaaa t1
order by t.col,t1.shapecode asc