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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:42:07+00:00 2026-06-13T09:42:07+00:00

Is it possible to have an IN statement within a left join clause? I

  • 0

Is it possible to have an “IN” statement within a left join clause?
I have two tables with two columns:

Table 1:                  Table 2:

Column1:                  Column2:

192192,                   192192
119202                    119202
810395                    810395
975643,                   975643
908574,,                  908574

As you can see, tbl1.col1 has entries can have entries with commas trailing or have none at all. I need to join the two tables where column 1 contains column 2 or where they are equal. It made sense to be to join where column1 includes column 2. Maybe there’s a better way to accomplish the join?

I need to join the two to access data in table 2. So the columns just need to align while allowing for a potential comma or two in column 1. Any suggestions?

  • 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-06-13T09:42:08+00:00Added an answer on June 13, 2026 at 9:42 am

    If this is just some sort of one-time deal or a staging table and not your real prod table:
    (this one works no matter where inteh number the commas are)

    select <column list>
    from table1 t1
    join table2 t2 on replace(t1.col1, ',','') = t2.col2
    

    or

    select <column list>
    from table1 t1
    join table2 t2 on  cast(t2.col2 as varchar (10)) like t1.col1+'%'
    

    (you may or may not need the cast depending onthe data types of the tow columns, I was assuming one was varchar and the other was integer)

    or
    (this only works if the value will always be the same length

    select <column list>
    from table1 t1
    join table2 t2 on left(t1.col1,6) = t2.col2
    

    If this is a real prod table, then you could have performance issues joining on a function, so fix the data instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to have a SELECT statement in mySQL with an IF/ELSE clause
Is it possible to have a many to many relationship between two tables, and
Is it possible to have a MySQLi prepared statement within the fetch() call of
I want to Join multiple tables using IF ELSE statement within Sql Query when
Is it possible for a receive statement to have multiple timeout clauses, and if
Possible Duplicate: Using a bitwise & inside an if statement I have the following
Is it possible have two projects with the same name in flex builder? Here
I have two tables, 'user' and 'account' with a 1:1 relationship. account has a
Possible Duplicate: MySQL number of items within “in clause” In mysql or postgres, is
I have one table view within the app that I hope multiple parts of

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.