none
Matching two fields in same table

    Question

  • I have a table with two columns containing Names (NameA and NameB columns)

    I want to match these two columns to find which rows don’t match, meaning they have different characters.

    TableA

    NameA              NameB    
    James Bond       James Bond

    Steve Ray          Steve Ray

    Ellie Golden       Natasha Kiss

    So the end result would return the last row only as the two names don’t match, how can I write a sql script to do this

    Tuesday, January 08, 2013 9:40 AM

Answers

  • Try the below:

    Select * From Table1 Where Col1<>Col2


    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    • Proposed as answer by Uwe RickenMVP Tuesday, January 08, 2013 9:49 AM
    • Marked as answer by Sam233 Tuesday, January 08, 2013 9:55 AM
    Tuesday, January 08, 2013 9:43 AM
  • Try

    select *

    from TableA

    where NameA<>NameB;


    Many Thanks & Best Regards, Hua Min

    • Marked as answer by Sam233 Tuesday, January 08, 2013 9:55 AM
    Tuesday, January 08, 2013 9:50 AM

All replies