SQL Query Help: Joining on where IN

  • Easier to demo than explain. Excuse the format, this is my first post.

    Is it possible to join on a partial match? See below. If i join on like '% + i.equipmentid + %' then i get I could join on 1234567 as well, which is an issue. 

    equipment.equipment id - 123456
    Invoice.equipmentid - 123456, 234567,3454678,1234567

    Thanks in advance.

  • it would be easier to help if we knew what the data looked like, can you provide DDL to create representative data?

    ***The first step is always the hardest *******

  • eric.breckenridge - Saturday, May 26, 2018 6:33 AM

    Easier to demo than explain. Excuse the format, this is my first post.

    Is it possible to join on a partial match? See below. If i join on like '% + i.equipmentid + %' then i get I could join on 1234567 as well, which is an issue. 

    equipment.equipment id - 123456
    Invoice.equipmentid - 123456, 234567,3454678,1234567

    Thanks in advance.

    It would probably be easier (and faster) for you to use a string splitter on your Invoice.equipmentid column and then to match on the split results.
    Here is a link to one of the best splitters around.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 3 posts - 1 through 2 (of 2 total)

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