skylab001 Posted November 14, 2007 Share Posted November 14, 2007 I was curious if there is a way to sort out duplicates in data returned by an query. I have a database, basically a mailing list database and when I query the database for the emails addresses, I get the returns echoed to the page as expected, but it looks like some people have signed up multiple times. So I have duplicates in my echoed list. Is there a way to have the data sort so the duplicates do not appear, and the email will only appear once on the list? I don't want people to be getting 5 of the same emails from me. Link to comment https://forums.phpfreaks.com/topic/77390-mysql-query-sorting-help/ Share on other sites More sharing options...
Barand Posted November 14, 2007 Share Posted November 14, 2007 SELECT DISTINCT emailaddress FROM mailing_list Link to comment https://forums.phpfreaks.com/topic/77390-mysql-query-sorting-help/#findComment-391763 Share on other sites More sharing options...
darkfreaks Posted November 14, 2007 Share Posted November 14, 2007 <?php mysql_select_db("db",$connect); $numrows= mysql_num_rows($query); if($numrows>1) {echo 'sorry but this email adress is already in use'; $query='DELETE FROM users WHERE email='$email'';}?> Link to comment https://forums.phpfreaks.com/topic/77390-mysql-query-sorting-help/#findComment-391766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.