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
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);
SELECT column,column2 FROM table WHERE last_login_ip = 'IPHERE';
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;
精彩评论