SELECT code FROM TABLEA
结果:CODE
COM50
COM88
COM106
COM73
COM27
COM33
COM23
我要怎么样在每列得到的结果加上2
想要结果:CODE
COM52
COM90
COM108
COM75
结果:CODE
COM50
COM88
COM106
COM73
COM27
COM33
COM23
我要怎么样在每列得到的结果加上2
想要结果:CODE
COM52
COM90
COM108
COM75
解决方案 »
- select id from A where id in (select id from B) 怎样提高执行速度?
- 将数据库表名myColumn改为变量如何写
- MM求救2
- 请高手看看这条SQL语句错在哪里
- 我用上面这段存储过程没有结果,大家看看是什么地方错了??如果我该成下面这种就有结果,帮帮忙!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 在oracle如何写sql文判断检索的数据是奇行还是偶行
- 如何对已有的数据分区?是不是只能建了分区后手工重新导入?
- 自动导入数据问题
- VFP单机版转换C/S模式问题?急!在线等待。
- 求sql查询语句!
- 如何限制SQL Server 2000 只接受来自某几个IP的连接?
- 棘手的查询
drop table tb
go
create table tb(code varchar(50))
insert into tb select 'COM50'
insert into tb select 'COM88'
insert into tb select 'COM106'
insert into tb select 'COM73'
insert into tb select 'COM27'
insert into tb select 'COM33'
insert into tb select 'COM23'update tb set code='COM'+ltrim(cast(replace(code,'com','') as int)+2)select * from tbCOM52
COM90
COM108
COM75
COM29
COM35
COM25
SELECT code+cast(2 as varcahr) FROM TABLEA
drop table tb
go
create table tb(code varchar(50))
insert into tb select 'COM50'
insert into tb select 'COM88'
insert into tb select 'COM106'
insert into tb select 'COM73'
insert into tb select 'COM27'
insert into tb select 'COM33'
insert into tb select 'COM23'update tb set code='COM'+ltrim(cast(replace(code,'com','') as int)+2)select * from tb
drop table tb
go
create table tb(code varchar(50))
insert into tb select 'COM50'
insert into tb select 'COM88'
insert into tb select 'COM106'
insert into tb select 'COM73'
insert into tb select 'COM27'
insert into tb select 'COM33'
insert into tb select 'COM23'
select 'COM'+ltrim(cast(replace(code,'com','') as int)+2) as code from tbCOM52
COM90
COM108
COM75
COM29
COM35
COM25会修改不会查询
code=
case when lift(code,3)=com then 'com'+((cast(substring(code,4)) as int)+2)
end
FROM TABLEA
from power_device,PARTNER P1,PARTNER P2,PARTNER P3,PARTNER P4
where p1.fupline=power_device.fconcentrator_no
and fdevice_code like '%COM%'
AND p1.fupline=p2.fpartner_code
AND p2.fupline=p3.fpartner_code
AND p3.fupline=p4.fpartner_code
是这句帮我改写fdevice_code这列加上2
select left(code ,patindex('%[0-9]%',code )-1)+
convert(varchar(8000),(convert(int,substring(code ,patindex('%[0-9]%',code ),8000))+2))
FROM TABLEA 或者select left(code ,3)+convert(varchar(8000),convert(int,right(code ,len(code )-3))+2)
FROM TABLEA
'COM'+ltrim(cast(replace(fdevice_code,'com','') as int)+2) as fdevice_code
from power_device,PARTNER P1,PARTNER P2,PARTNER P3,PARTNER P4
where p1.fupline=power_device.fconcentrator_no
and fdevice_code like '%COM%'
AND p1.fupline=p2.fpartner_code
AND p2.fupline=p3.fpartner_code
AND p3.fupline=p4.fpartner_code
SELECT 'COM'+LTRIM(CONVERT(INT,(REPLACE(CODE,'COM','')))+2) AS CODE FROM TB
update table
set code = 'COM'+convert(char(3),substring(code,4,len(code))+2)
drop table test.dbo.tb
create table tb(code varchar(100))
insert tb
select 'com50'
union all
select 'com88'
union all
select 'com106'
union all
select 'com73'
union all
select 'com27'
union all
select 'com33'
union all
select 'com23'select * from tbselect left(code,3)+cast(cast(substring(code,4,len(code)) as int)+2 as varchar(10)) from tb
select code from tb for update of code
open a
declare @code varchar(100),@i int, @b int
fetch next from a into @code
while @@fetch_status=0
begin
select @b=(select len(code)-3 )from tb where code=@code
set @i=cast(right(@code,@b) as int)+2
update tb set code=left(code,3)+cast(@i as varchar) from tb where current of a
fetch next from a into @code
end
close a
deallocate a