I'm having the following problem:
Let's assume I have a table with 3 fields: ID (type int), NAME(type varchar), EMAIL (type varchar) in a mysql db.
The fields have the following data stored:
1, jack, firstname.lastname@example.org
2, tom, email@example.com
3, jack, firstname.lastname@example.org
2000, jack, email@example.com
Now let's say I have like some thousand entries like that one above with each one containing different data. So if there are entries which have the same email adress, how I can I select exclusively those entries with the duplicate data in it?
So the result of a selection should look something like this:
(If I want to show the selection results in html):
<td>First matching duplicate entry.</td>
<td>Second matching duplicate entry.</</td>
<td>1, jack, [email]firstname.lastname@example.org[/email]</td>
<td>2, tom, [email]email@example.com[/email]</td>
what does the php code have to look alike?
so far I got this mysql query:
SELECT id, email FROM table WHERE COUNT(email)>1
which is working fine but I don't know how I can get these results showing up with each row that has the duplicate entry.
I did this:
$query = "SELECT email,count(email) from table group by email having count(email) > 1";
$result = mysql_query($query);
while($row = mysql_fetch_object($result))
how do I get those duplicate results showing up in an html table with two columns?