例如:我有两个表,A和B,A中有个字段name,它的值是:"令狐冲",B表中有个字段namelist,它的值是:"段誉,令狐冲,萧峰",怎样用Sql语句判断A表中的name字段的值是否在B表中namelist字段的值中包含?
3 个解决方案
#1
select 1 from B where CHARINDEX ('令狐冲',namelist)>0
#2
select A.NAME,B.NAMELIST from A,B where AT(ALLTRIM(A.NAME),B.NAMELIST)>0
或者
select A.NAME,B.NAMELIST from A,B where AT('令狐冲',B.NAMELIST)>0
#3
谢谢lygcw9602
#1
select 1 from B where CHARINDEX ('令狐冲',namelist)>0
#2
select A.NAME,B.NAMELIST from A,B where AT(ALLTRIM(A.NAME),B.NAMELIST)>0
或者
select A.NAME,B.NAMELIST from A,B where AT('令狐冲',B.NAMELIST)>0
#3
谢谢lygcw9602