note 39885 deleted from function.mysql-query by mazzanet

From: Date: Sun, 02 Oct 2005 13:26:07 +0000
Subject: note 39885 deleted from function.mysql-query by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96180@lists.php.net to get a copy of this message
Note Submitter: jlsalinas at spamsucks dot gmx dot net ---- In response to Johann Eckert (11-Feb-2004 11:08), I think there is a better way to look for repeated entries. SELECT column, count(column) as c FROM table GROUP BY column HAVING (c > 1); In this case, we are interested in *only* repeated entries. We can remove the HAVING clause if we also want to get the entries with just one occurrence. We can also add a ORDER BY c DESC clause to get the most repeated entries first. Last but not least, if 'c' doesn't work in the HAVING and ORDER clauses (I've never had that problem, but I suspect it may happen with some DBMS), try substituting it with 'count(column)'.

« previous php.notes (#96180) next »