Page 1 of 1

search for row duplicates

Posted: Mon Apr 05, 2010 12:51 pm
by rafaell
I have a database where in 2 columns some of the information is repetitive.
Ex:
col1, col2
1,2
2,4
1,3
1,2
1,2
2,5
2,4

And I want to search the rows and just pull out the unique ones, leaving out the duplicates.
So in the above example, I'd be left with:
1,2
2,4
1,3
2,5

I'm guessing an array, but can't figure out the comparison part to see which one is unique.

Re: search for row duplicates

Posted: Mon Apr 05, 2010 2:01 pm
by requinix
Use DISTINCT.

Code: Select all

SELECT DISTINCT * FROM `table`