在线请教查询的字段~~
已知A表的值有
id 地址1 地址2 地址3
002 guangzhou chengdu nanjing
如何查询在B表里面含有 地址1+地址2+地址3 (guangzhouchengdunanjing) 的字段
B表:
id ComAddress ComCity
A001 guang nan
A002 hubei dong
A003 chengdu xinjian
A004 xiaoxin linken
.
.
.
最后找到的条件应该是B表里的
A001 guang nan
[解决办法]
create table A(id varchar(3),地址1 varchar(30),地址2 varchar(30),地址3 varchar(30))create table b( id varchar(10), ComAddress varchar(30), ComCity varchar(30) )insert into A select '002', 'guangzhou', 'chengdu', 'nanjing'insert into b select 'A001', 'guang', 'nan' union allselect 'A002', 'hubei', 'dong' union allselect 'A003', 'chengdu', 'xinjian' union allselect 'A004', 'xiaoxin', 'linken' select t1.* from b t1,A t2 where CHARINDEX(t1.ComAddress ,t2.地址1 + t2.地址2 + t2.地址3 ) >0 and CHARINDEX(t1.ComCity ,t2.地址1 + t2.地址2 + t2.地址3 ) >0id ComAddress ComCity---------- ------------------------------ ------------------------------A001 guang nan(1 行受影响)