日期:2014-05-17  浏览次数:20408 次

求一条sql查询语句(在线等)
有两个表:A和B
-------------------------------------------
A表数据:
typeid   parentid......
  1         3
  2         3
  3         3
  4         4
  5         4
  6         3
--------------------------------------------
B表数据:
...typeids...
   2,3,5,8
   4,5
   1,3,6
---------------------------------------------
怎么能把B表typeids字段中包含A表parentid=3的数据查出来.
SQL

------解决方案--------------------
select b.*
from a
join b on charindex(','+ltrim(a.typeid)+',',','+b.typeids+',')>0
where a.parentid=3