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

  • SEARCH
  • Home
  • 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 3284504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:09:43+00:00 2026-05-17T20:09:43+00:00

My query is based on the following example I have table say ‘Table1’. Table1

  • 0

My query is based on the following example

I have table say ‘Table1’. Table1 has one row and one column. The name of the column is ‘Column1’. ‘Column1’ is a text column (NVARCHAR). I have a comma separated keywords like ‘key1,key2..keyn’. I want to search these keywords individually in the column1.

So in the where clause the query should be something like

SELECT ... FROM Table1
WHERE Column1 LIKE '%key1%'
AND Column1 LIKE '%key2%'
AND Column1 LIKE '%keyn%'

I just want to know how to write a query in a simplified manner. Table is quite small and performance is not a main concern.

Just declare the keywords in a variable for the test case

DECLARE @Keywords NVARCHAR(MAX)
SET @Keywords = 'Key1,Key2,Key3'

A simple example will be helpful to me.

  • 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-17T20:09:44+00:00Added an answer on May 17, 2026 at 8:09 pm

    This will be easier if you get these into table format. (Split Table Valued functions exist to do this to your delimited string – e.g. http://www.eggheadcafe.com/community/aspnet/13/10021854/fnsplit.aspx)

    DECLARE @Keywords TABLE
    (
    COL NVARCHAR(100)
    )
    
    INSERT INTO @Keywords SELECT 'Key1' UNION ALL SELECT 'Key2' UNION ALL SELECT 'Key3'
    
    SELECT ... 
    FROM Table1  c 
    JOIN @Keywords k ON c.Column1  LIKE '%' + k.COL + '%'
    GROUP BY  ...
    HAVING COUNT(*) = (select COUNT(*) FROM @Keywords)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run an update query that updates one table based on rows
I have a report in SSRS 2005 that's based on a query that's similar
Query parameters : http://example.com/apples?order=random&color=blue Matrix parameters : http://example.com/apples;order=random;color=blue When should one use query parameters
I have a need to create a LINQ query that returns results based on
I have the following data returned buy a simple SQL query. The Number of
I have a query that fetches employee's name, date, working hours, wage and calculate
I'm trying to create a linq query based on some dynamic/optional arguments passed into
I'd like to build a query string based on values taken from 5 groups
Why don't databases automatically index tables based on query frequency? Do any tools exist
I use a view based on a complex query with 17 joins (both inner

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.