日期:2014-05-16  浏览次数:20531 次

SQL表连接
表lwnhry   列ry                             表lwmain  列ry

                   张三                                              张三 李四 王五

                   李四                                               张三 李四 赵六

                   王五                                                 张三 李四

                   赵六                                                 王五 

                  孙七                                                   李四

                  周八                                                   赵六
                 

想获取的是 lwnhry ry列中数据在lwmain  列ry中有的,怎么写呢?
------解决方案--------------------
select a.ry from lwnhry a, lwmain b where charindex(a.ry, b.ry) > 0 楼主赐分吧