A表的RecordID(int)是否在B表的一个varchar值中?
表A: 字段recordID 类型int 为标识列
表B: 字段relationList 类型varchar 值:3,4,5
写语句如下:
SELECT A.*,B.*
FROM A,B
WHERE A.RecordID=638
AND convert(varchar,A.RecordID) IN (B.relationList)
程序无法正确执行.如果哪位仁兄,知道请解答一下,谢谢!
------解决方案--------------------select
*
from
A,B
where
charindex( ', '+rtrim(A.RecordID)+ ', ' , ', '+B.relationList+ ', ' ) > 0