日期:2014-05-17 浏览次数:20436 次
create table a (a varchar(20))
insert into a values('123')
insert into a values('245')
insert into a values('445')
insert into a values('4542')
insert into a values('456')
create table b (b varchar(20))
insert into b values('123456')
insert into b values('55456')
insert into b values('45896')
go
select a.a , b.b from a , b where charindex(a.a , b.b) > 0
/*
a b
-------------------- --------------------
123 123456
456 123456
456 55456
(所影响的行数为 3 行)
*/
select a.a , b.b from a , b where b.b like '%' + a.a + '%'
/*
a b
-------------------- --------------------
123 123456