Question: I am not sure how to do ask this...

Is it possible to have mysql scan a whole column in a whole table and finds an identical match or matches.

So it would be something like...

```
$q = $pdo("SELECT ip FROM accounts");
$q -> execute();
$results = $q -> fetch(PDO::FETCH_ASSOC);

if (there is 2 of same ip) {

}

```

Thanks

Answer: 
If you're looking for duplicates, the following SQL should give you any IPs listed two or more times in your accounts table.

```
$q= $pdo("SELECT ip FROM accounts GROUP BY ip HAVING COUNT(ip) > 1");
$q->execute();
$duplicateIPs = $q->fetch(PDO::FETCH_ASSOC);

```
You should try something along the lines of 

```
SELECT `a`, `b`, COUNT(`a`) AS cnt FROM `table` AS t GROUP BY t.`a` ORDER BY cnt DESC;

```