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 3484456
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:47:25+00:00 2026-05-18T10:47:25+00:00

If I have to search for some data I can use wildcards and use

  • 0

If I have to search for some data I can use wildcards and use a simple query –

SELECT * FROM TABLE WHERE COL1 LIKE '%test_string%'

And, if I have to look through many values I can use –

SELECT * FROM TABLE WHERE COL1 IN (Select col from AnotherTable)

But, is it possible to use both together. That is, the query doesn’t just perform a WHERE IN but also perform something similar to WHERE LIKE? A query that just doesn’t look through a set of values but search using wildcards through a set of values.

If this isn’t clear I can give an example. Let me know. Thanks.

Example –

lets consider –

AnotherTable –

  id  | Col
------|------
  1   |  one
  2   |  two
  3   |  three

Table –

Col   | Col1
------|------
 aa   |  one
 bb   |  two
 cc   |  three
 dd   |  four
 ee   |  one_two
 bb   |  three_two

Now, if I can use

SELECT * FROM TABLE WHERE COL1 IN (Select col from AnotherTable)

This gives me –

Col   | Col1
------|------
 aa   |  one
 bb   |  two
 cc   |  three

But what if I need –

Col   | Col1
------|------
 aa   |  one
 bb   |  two
 cc   |  three
 ee   |  one_two
 bb   |  three_two

I guess this should help you understand what I mean by using WHERE IN and LIKE together

  • 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-18T10:47:26+00:00Added an answer on May 18, 2026 at 10:47 am
    SELECT * 
    FROM TABLE A
       INNER JOIN AnotherTable B on
         A.COL1 = B.col
    WHERE COL1 LIKE '%test_string%'
    

    Based on the example code provided, give this a try. The final select statement presents the data as you have requested.

    create table #AnotherTable
    (
        ID int IDENTITY(1,1) not null primary key,
        Col varchar(100)
    );
    
    INSERT INTO #AnotherTable(col) values('one')
    INSERT INTO #AnotherTable(col) values('two')
    INSERT INTO #AnotherTable(col) values('three')
    
    create table #Table
    (
        Col varchar(100),
        Col1 varchar(100)
    );
    
    INSERT INTO #Table(Col,Col1) values('aa','one')
    INSERT INTO #Table(Col,Col1) values('bb','two')
    INSERT INTO #Table(Col,Col1) values('cc','three')
    INSERT INTO #Table(Col,Col1) values('dd','four')
    INSERT INTO #Table(Col,Col1) values('ee','one_two')
    INSERT INTO #Table(Col,Col1) values('ff','three_two')
    
    SELECT * FROM #AnotherTable
    SELECT * FROM #Table
    
    SELECT * FROM #Table WHERE COL1 IN(Select col from #AnotherTable)
    
    
    SELECT distinct A.*
    FROM #Table A
        INNER JOIN  #AnotherTable B on
            A.col1 LIKE '%'+B.Col+'%'
    
    DROP TABLE #Table
    DROP TABLE #AnotherTable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On my homepage I have a simple search form. The user can enter some
I have to use NSPredicate for search through some Core Data objects. But the
I have a MySQL/Rails app that needs search. Here's some info about the data:
I have a simple script that does some search and replace. This is basically
I can get data from MySql with use of php using android successfully. But
As the title suggests I would like to be able to use data from
i have need webpage-content. I need to get some data from it. It looks
So I have a webpage that queries some data based on this parameter search.php?state=AL
Can you advise on whether I can use just the Query functionality from Lucene
I have already search for some time over the net on how to create

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.