要么你数据库设计有问题。
这没法一起查,查出来的都是2表堆在一起的,实在要查的话这样
select a.*,b.* from a,b where a.it=b.code and b.code='S'
Sql Server 如下:
一:
select * from a where exists
(select 1 from b where code='S' and b.value+',' like '%'+a.it+',%' )
二:
select * from a where
(select count(1) from b where code='S' and b.value+',' like '%'+a.it+',%' ) >0
用like进行模糊查询
select * from A where it like (select code from B where code like 'S%')
select * from a,b where a.it=b.code and b.code='S'