View Single Post
Old Dec 3rd, 2007, 9:12 AM   #1
davil
Newbie
 
Join Date: Nov 2007
Posts: 27
Rep Power: 0 davil is on a distinguished road
Select Non distinct in MySQL

Hi all,

I know this isn't exactly PHP but I was wondering if there's a simple MySQL query you can use to get back non-distinct lines... like for example you can use SELECT DISTINCT to only give you back the rows with that unique value in a field or whatever... but I'm looking to do the opposite.. I can filter the data with PHP if needs be but I'd much prefer to only get the correct data from the SQL instead and leave unneeded programming out of it...

I have a field called mac address on my DB and there are duplicate items and I simply want to be able to pull up details for the mac addresses that are reported twice so I can remove old data from the DB....

for example, if I wanted to get back unique mac addresses on the DB only I would do this:

php Syntax (Toggle Plain Text)
  1. $sql = "SELECT DISTINCT `primarymac` FROM `aidahardware` ORDER BY 'datestamp' DESC";
  2. $result = mysql_query($sql) or die(mysql_error());

but how do I do the exact opposite??

Any help is much appreciated as I cannot find the answer I'm looking for through google etc.
davil is offline   Reply With Quote