Peter
Peter

Reputation: 875

Mysql removing duplicates based on one column

I am using the query below

      $result2 = mysql_query("select * from HandsetStock WHERE SubCategory NOT LIKE '%clearance%'", $dbh2);

I am getting a few duplicate results which I want to eliminate from the results however they are not completely duplicate rows. The column name is Make. I am guessing i need some kind of subquery but I am struggling to get it to work for me. Basically I need to select all records but where Make has the same value just the first record.

Thanks

Upvotes: 1

Views: 1165

Answers (1)

Shakti Singh
Shakti Singh

Reputation: 86396

 $result2 = mysql_query("select * from HandsetStock 
                        WHERE SubCategory NOT LIKE '%clearance%' 
                        group by Make", $dbh2)

Upvotes: 2

Related Questions