Looking Up List of Partial Strings

  • carminamae.gonzales

    Newbie

    Points: 9

    Hi,
    I was hoping someone could please help me.... I am using TSQL and was aiming to be able to be able to complete my query by completing the set of partial strings. I have inserted a sample of what I needed to do (see image). Initially, I only have the column names: "Partial Strings" and I have a separate Table named "Lookup List". Limitations are:
    1. No other objects to be used as their unique identifier.
    2. "Partial Strings" have no specific number of characters, and can appear in as little as 2 first characters

  • pietlinden

    SSC Guru

    Points: 62347

    Don't think it will work unless the first 2 characters of a the strings are unique, so you wouldn't have something like
    Ball
    Bath
    as members of the set. If that's the case, that solution won't work.

  • carminamae.gonzales

    Newbie

    Points: 9

    The first 2 characters is always unique in my data set...

  • Jonathan AC Roberts

    SSCoach

    Points: 16459

    carminamae.gonzales - Wednesday, February 27, 2019 6:33 AM

    The first 2 characters is always unique in my data set...

    If you have a number of characters that a string begins with, to find that string on the database you just need a query using like.
    e.g:
    SELECT *
      FROM dbo.[Given List] g
     INNER JOIN dbo.[Separate Table] t 
             ON t.[Lookup List] LIKE g.[Partial String] + '%'

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply