同意楼上的,select a_1 from table2 where type=2返回值 应添加相应的通配符如:%、[]、^等等,具体看帮助
不同意: popcode(紫枫 Plus)说的好象是把 [%"&(select a_1 from table2 where type=2)&"%]当作一字符串来处理了!要不like后面跟结果集就会有语法错误
select * from table where type like 'abe'+'%'ok
如果select a_1 from table2 where type=2的结果集大于一,则不能,否则可以!要实现你的功能可以使用游标与临时表的结合!
你可以试一试: select a1,b1 from table1 where a1 in ( select distinct a.a1 from (select a.a1,b.a_1 from (select 'A' as Col1,a1 from table1) a left join (select 'A' as Col1,a_1 from table2 where type=2) b on a.Col1=b.Col1) a where ltrim(rtrim(a.a1)) like '%'+ltrim(rtrim(a.a_1))+'%' )
应添加相应的通配符如:%、[]、^等等,具体看帮助
popcode(紫枫 Plus)说的好象是把 [%"&(select a_1 from table2 where type=2)&"%]当作一字符串来处理了!要不like后面跟结果集就会有语法错误
select * from table where type like 'abe'+'%'ok
select a1,b1 from table1 where a1 in (
select distinct a.a1 from
(select a.a1,b.a_1 from
(select 'A' as Col1,a1 from table1) a
left join
(select 'A' as Col1,a_1 from table2 where type=2) b
on a.Col1=b.Col1) a
where ltrim(rtrim(a.a1)) like '%'+ltrim(rtrim(a.a_1))+'%'
)