DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: How to select the rows that have the same values in some columns?

Hybrid View

  1. #1
    Join Date
    Jan 2001
    Posts
    59

    data in table 'TEST':

    column01, column02, column03
    AAA, AAA,AAA
    ABC,ABC,ABC
    ACB, ACB, ACB
    BAC, AAA, BAC



    You can see that values of the column 'column02' are the same for the first row and the fourth row. They are both 'AAA'.


    I would like to find out which value is duplicated in a certain column by executing a SQL select query. is this possible?

    Thanks.










  2. #2
    Join Date
    Aug 2000
    Posts
    194
    You culd do something like,

    select A.* from myTable A, myTable B
    where A.col1 = B.col1 or A.col2 = B.col2 or A.col3 = B.col3

    Note: I haven't tested how good it performs

  3. #3
    Join Date
    Jan 2001
    Posts
    59

    I should have made my question more clear. Actually what I wanted to do is a query like


    select a.column02 from TEST a, TEST b where a.column02 != b.column02 and a.column03 = a.column03



    i just realized that it is not that complicated as i thought since the value of column03 is has to be distinct, but thanks anyway.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width