note 39885 added to function.mysql-query

From: Date: Sat, 14 Feb 2004 01:23:39 +0000
Subject: note 39885 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-65126@lists.php.net to get a copy of this message
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)'. ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39885 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39885&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39885&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65126) next »