I am trying to select records where the Id exists in a comma delimited string but the query below doesn't return any results:
SELECT * FROM [SellPost] WHERE CAST([AutoId] AS nchar(100))
IN (SELECT [SellPostId] FROM [SellPostViewHistory]) -- SellPostId contains the delimited string
The statement 'SELECT [SellPostId] FROM [SellPostViewHistory]' will return 19,20,21 and if I replace the query with
SELECT * FROM [SellPost] WHERE CAST([AutoId] AS nchar(100))
IN (19,20,21)
it works. Can someone please kindly advice. Thanks.