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.

    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.

  • 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