I've been trying the following:
select max(field1),email from t group by email
or my code is infact:
$sql = "SELECT MAX(CONTACT_ALLOW), EMAIL, ID FROM table GROUP BY EMAIL";
$result = mysql_query($sql) or die("Error...");
while($row = mysql_fetch_array($result))
{
$ID = $row['ID'];
$email = $row['EMAIL'];
echo("$email , $ID<BR>");
}
This code returns the unique email addresses like it should do (CONTACT_ALLOW is either 1 or 0), but some of them are not the maximums from a column:
ID | CONTACT_ALLOW | EMAIL
1 | 0 |test@test.com
2 | 1 |try@try.com
3 | 1 |help@help.com
4 | 1 |test@test.com
5 | 0 |help@help.com
6 | 0 |try@try.com
In the above example it takes the rows with the following ID's:
1,2,3 wheras it should take: 2,3,4
Any Ideas??