
July 11th, 2007, 19:19 PM
|
| Administrator
Join Date: Jun 2007
Posts: 3,709
BRL$: 42,914.45 Thanks: 0
Thanked 14 Times in 10 Posts
Rep Power: 409 | | MySQL display duplicate entries I'm trying to go through a mysql database and display all the records that have a duplicate telephone number. The code below seems to only get the first record that has a duplicate but not all the records that have a duplicate. $query = "SELECT *, count(*) cnt FROM newtab GROUP BY phone HAVING cnt > 1"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $lastname = $row['lastname']; $firstname = $row['firstname']; $phone = $row['dayphone']; echo "Duplicate record - $firstname, $lastname, $phone"; } To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts. | |
__________________ █ High Quality To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
█ Powerful To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
█ To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. █ Jobs In !!! - Post Jobs, Hire Employees, Create Blogs and
Earn Money. | | | |