27,579
社区成员
发帖
与我相关
我的任务
分享
declare @Tab table (address varchar(10))
insert into @Tab
select '北京路' union all
select '北京西路' union all
select '北京南路' union all
select '北京小路' union all
select '南京西路' union all
select '上海二路' union all
select '广州河堤路'
select * from @Tab where SUBSTRING(address,0,2) =SUBSTRING('北京西路',0,2)
declare @T table (地址 varchar(10))
insert into @T
select '北京路' union all
select '北京西路' union all
select '北京南路' union all
select '北京小路' union all
select '南京西路' union all
select '上海二路' union all
select '广州河堤路'
--是不是这个意思?
declare @p varchar(40)
set @p='北京西路'
select * from @T where left(地址,2)=left(@p,2)
/*
地址
----------
北京路
北京西路
北京南路
北京小路
*/