Jump to content

How to use the Having Clause


SchweppesAle

Recommended Posts

Hi, I've used the following query to check for any duplicate email addresses in our table.  The problem is, I'm not entirely sure what the difference is between both the having and where clauses so I was hoping someone could confirm whether this would work or not.

 

 

SELECT COUNT(id) AS Quantity 
FROM huge_email_list 
GROUP BY email 
HAVING ( COUNT(email) = 1 )

 

My concern is that the query will eliminate email addresses which have multiple entries from the total sum(Quantity) entirely rather than counting them as an additional 1 entry. 

 

Is this where the Having clause comes into play? 

Link to comment
https://forums.phpfreaks.com/topic/202994-how-to-use-the-having-clause/
Share on other sites

Alright, this clearly wasn't working :P

 

Thinking that I might just need to include the GROUP BY email clause in order to count the unique email addresses

 

Still, I was hoping someone could clarify the difference between WHERE and HAVING; I really can't tell the difference. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.