I am using .NET 4.0 & C# and SQL Server 2008. I have a table Products with a column called Keywords. I have another table Interests with 2 columns Accept and Reject. All 3 columns contains keywords separated by commas. I need to match:
- If Accept & Reject are empty, then there is a match
- If Accept has keywords, then there should be at least 1 keyword match between Accept & Keywords
- If Reject has keywords, then there should be no matches between Reject & Keywords
- Combination of 2 & 3
Ideally I'd like to do this in a SQL query. I'm open to stored procedures either Managed or T-SQL in that order.
OK, based on the comments, I've added these tables:
Keywords_Products [id (FK to Products), Keyword]
Keywords_Accepted [id (FK to User), Keyword]
Keywords_Rejected [id (FK to User), Keyword]
So, I need a set of products for a given userId, based on the 4 rules above.