List:General Discussion« Previous MessageNext Message »
From:Tim Thorburn Date:June 14 2003 11:14pm
Subject:selecting DISTINCT and COUNT in MySQL
View as plain text  

I'm setting up a small tracking program for a site I'm working on - 
basically it monitors all external web and email links that are clicked 
from our site and stores them into a MySQL database.

Now I'm trying to extract the information from the database and display it 
on screen with PHP.  I've made a query which reads:

This clearly selects all the distinct email addresses from my table, but I 
would like to put a count beside each of the distinct addresses to show how 
many times each link was clicked.

For example, I'd like it to look something like the following:

email address               # sent
fake@stripped              12

Meaning that the email addresses 'fake@stripped' was clicked a total of 12 

I'm thinking there should be a way to do this with a single SQL query ... 
although after most of the day of trying and searching google - I've come 
up with nothing but a headache.

Any thoughts?


selecting DISTINCT and COUNT in MySQLTim Thorburn15 Jun
  • RE: selecting DISTINCT and COUNT in MySQLPeter Lovatt15 Jun