Searching a part of String in string Column

  • Hi,

    I require a little help on string query.

    I have two table ( Table A and Table B) each having employee column with string values.

    I want to search that does part of Table A.employee column is having matching value in Table B.employee column

    Table A. Employee

    -----------------

    Steve Smith

    John Davis

    Table B. Employee

    -----------------

    Steve Craig

    Peter Thomas

    I want to search if Employee having name "Steve" from table A is having matching value from TableB. Employee.

  • chetanr.jain (9/8/2010)


    Hi,

    I require a little help on string query.

    I have two table ( Table A and Table B) each having employee column with string values.

    I want to search that does part of Table A.employee column is having matching value in Table B.employee column

    Table A. Employee

    -----------------

    Steve Smith

    John Davis

    Table B. Employee

    -----------------

    Steve Craig

    Peter Thomas

    I want to search if Employee having name "Steve" from table A is having matching value from TableB. Employee.

    Not sure what you are asking for here. Based on the above, would Steve Smith in Table A match Steve Craig in Table B?

  • What if you have numerous employees with (for example) the first name of "steve" in both tables? Any join on part of a string (or substring) is going to bring you back some interesting results. Be worth double checking the requirements and business rules

  • chetanr.jain (9/8/2010)


    Hi,

    I require a little help on string query.

    I have two table ( Table A and Table B) each having employee column with string values.

    I want to search that does part of Table A.employee column is having matching value in Table B.employee column

    Table A. Employee

    -----------------

    Steve Smith

    John Davis

    Table B. Employee

    -----------------

    Steve Craig

    Peter Thomas

    I want to search if Employee having name "Steve" from table A is having matching value from TableB. Employee.

    The solution to this is fairly trivial. The name string is resolved out as words in separate rows, enabling a common JOIN to match the two tables.

    But as others have pointed out, what on earth would you want to do this for?

    An explanation of what this operation is expected to achieve would be helpful. If you're really looking to detect matches on full name - e.g. "Craig, S." matching "Steve Craig" then it will be quite a lot more complex.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

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

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