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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:58:01+00:00 2026-05-26T16:58:01+00:00

I have two tables with lists of files: table1 has column1 with file names

  • 0

I have two tables with lists of files: table1 has column1 with file names that begin with the string ‘STO-‘ followed by a string pattern. So in total, the string has 16 alphanumberic characters (with dashes its a 20-character string).
This is similar to the same file name string found in table2, column1. The issue, however, is that in the first table there are also additional text and characters appended to that 20-digit string. I’m attempting to match results from both tables where those 20-digit character strings match, along with additional information from the table. I’ve found plenty of information about pattern matching within a table, but not comparing two tables. Hopefully I’m explaining myself and can provide an example to help:

TABLE1.Column1 contains a file name ‘STO-100-XX-XXXX-XXXX_Text.pdf ‘

TABLE2.Column2 contains a file name ‘STO-100-XX-XXXX-XXXX.pdf’ and TABLE2.Column3=’Y’

So again, I’m trying to see the list of files from TABLE1 that where the first 20 alphanumeric character string has a match from TABLE2.

  • 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-26T16:58:01+00:00Added an answer on May 26, 2026 at 4:58 pm
    SELECT * from TABLE1 t1
    INNER JOIN TABLE2 t2
    ON SUBSTRING(t1.Column1, 1, 20) = SUBSTRING(t2.Column2, 1, 20)
    

    (tested on SQL Server 2005, but I believe SUBSTRING is an ANSI SQL function, so should work on most databases).

    Also, it’s a little unclear from your question, but if you additionally wanted to restrict the results based on column3, you would simply do

    SELECT * from TABLE1 t1
    INNER JOIN TABLE2 t2
    ON SUBSTRING(t1.Column1, 1, 20) = SUBSTRING(t2.Column2, 1, 20)
    WHERE t2.Column3 = 'Y'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a repo that has two files that supposedly I changed locally. So
I have two tables: Users and Files . Users table has 10 rows, Files
I have database which has two tables post: id post_name post_desc files: file_id file_name
I have two tables names book_list and book_category . Schema is like below: book_list
I have two tables. indRailType contains a list of the names paired with an
I have two tables. One (Widgets) has a list of widgets (ID, widget_name, color,
I have a list of addresses in two separate tables that are slightly off
I have two lists which have been created by .csv files. The first consists
I have two datatables, one which lists foldes, and another which list's files within
I have 3 different types of files in a folder. Every file has same

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.