Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 987721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:31:35+00:00 2026-05-16T05:31:35+00:00

I am using .NET 4.0 & C# and SQL Server 2008. I have a

  • 0

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:

  1. If Accept & Reject are empty, then there is a match
  2. If Accept has keywords, then there should be at least 1 keyword match between Accept & Keywords
  3. If Reject has keywords, then there should be no matches between Reject & Keywords
  4. 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:31:36+00:00Added an answer on May 16, 2026 at 5:31 am

    If you are stuck with the table structure as-is (and I suspect that you are), then you’re probably best off breaking this up into multiple pieces. Your first piece is to create a function that can split strings based on a delimiter. How to do so has been answered well in another question.

    It’d also help if you create a refinement on the split function by creating one specific to the Keywords field on the Products table. Something where you can pass in the ProductId and have it return the keywords for that ProductId.

    From there, you can select interests matching a given product with something like

    SELECT * FROM Interests i
    WHERE 
        (i.Accept = '' AND i.Reject = '')
        OR
        (
            EXISTS (SELECT * FROM Split(',', i.Accept) ia WHERE ia.[Value] IN (ProductKeywords(@ProductId)))
            AND
            NOT EXISTS (SELECT * FROM Split(',', i.Reject) ir WHERE ir.[Value] IN (ProductKeywords(@ProductId)))
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The application is planned to be built using ASP.NET, .NET Remoting & MS SQL
Using .NET 1.1, I have a DataGrid that contains three columns for each row.
We are using C#, ASP.NET & WCF. I am trying to send form data
I'm using C# & .NEt 3.5. What is the difference between the OptionA and
Is there an ASP.NET AJAX framework other than just using UpdatePanel & Friends or
I've created an web authentication app using c# & asp.net and want to bounce
Using .Net (C#), how can you work with USB devices? How can you detect
Using .Net 3.0 and VS2005. The objects in question are consumed from a WCF
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging
I am using .NET remoting to retrieve periodic status updates from a Windows service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.