我正在尝试选择 Id 存在于逗号分隔字符串中的记录,但下面的查询不返回任何结果:
SELECT * FROM [SellPost] WHERE CAST([AutoId] AS nchar(100))
IN (SELECT [SellPostId] FROM [SellPostViewHistory]) -- SellPostId contains the delimited string
语句 'SELECT [SellPostId] FROM [SellPostViewHistory]' 将返回 19,20,21,如果我将查询替换为
SELECT * FROM [SellPost] WHERE CAST([AutoId] AS nchar(100))
IN (19,20,21)
有用。有人可以请教。谢谢。