Highlighting duplicate values in one record

  • I have 3 columns in a large database, all containing telephone numbers. I need to highlight the records where the same value appears in for example, Column 1 AND Column 2.

    Any help would be appreciated.

    Tony Harrison

  • Something like this? 

     

    Select Phone1, Phone2, Phone3 from Table

    where Phone1 = Phone 2

    or Phone1 = Phone3

    or Phone2 = Phone3

  • Thanks very much. I have tried this, but the problem is that the fields which currently contain no number and are blank, are matching with each other!

    Is there a way of stopping this from happening?

    Yours confusingly,

    T Harrison

  • add that condition to the where clause:

    select

    Select Phone1, Phone2, Phone3 from Table

    where (Phone1 = Phone 2

    or Phone1 = Phone3

    or Phone2 = Phone3)

    and ltrim(rtrim(phone1)) <> ''

    and ltrim(rtrim(phone2)) <> ''

    and ltrim(rtrim(phone3)) <> ''

  • That's great, thanks very much!

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

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