Selecting only one occurrence from a column


/ Published in: SQL
Save to your folder(s)

DISTINCT will produce more results if a user had been added with more than one type of newsletter. The GROUP BY clause will just get the single email.


Copy this code and paste it in your HTML
  1. SELECT DISTINCT(email), newsletter FROM contact_tbl WHERE newsletter != 0;
  2.  
  3. SELECT email, newsletter FROM contact_tbl WHERE newsletter != 0 GROUP BY email;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.