sql语句,根据地区ID编号取对应的地区名称
发布网友
发布时间:2022-04-09 06:19
我来回答
共2个回答
热心网友
时间:2022-04-09 07:48
select (select name from t where code=substring(a.code,1,3)+'000' ) 省,
(select name from t where code=substring(a.code,1,4)+'00' ) 市,
name 区 from t a where substring(code,5,2)<>'00'
热心网友
时间:2022-04-09 09:06
select shname,shiname,name from table
inner join
(
(
select name as shname , left(code,2) as shcode from table
where right(code,4) = '0000'
)
inner join
(
select name as shiname , left(code,2) as shicode from table
where right(code,2) = '00'
and right(code,4) <> '0000'
)
on shcode = shicode
)
on left(code,2) = shcode