search the value of a field as a substring of another field.

  • Hi all,

    I have the following query:

    Select mx.vserie, mx.vfolio 
    from data1 mx
    inner join data2 my on mx.vfolio = my.voucher

    I need to search the value of mx.vfolio as a substring of my.voucher.

    Any ideas?

    thank you in advance.

  • Sure. Use CHARINDEX to search for one string within another.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Just plan on such a thing doing full table scans because the JOIN criteria will become non-SARGable.

     

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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