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.


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

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