Hi All,
I have be struggling with this trying to get the right query to work, but when I try to test it each time it fails. May I have some assistance with this please.
What I want the query to do is get the distinct City, then count the number of records for that City from the database.
I can do this in two steps in PHP with separate queries, but I want to do this more efficent.
What I have for the first part is:
SELECT DISTINCT(CITY) FROM MY_DB
The second statement is:
SELECT COUNT(ID) AS CITYCOUNT FROM MY_DB WHERE CITY = '$city'
What I tried was an INNER JOIN, however my skills on SQL are rather limited.
What I want the end result to be is that when I loop through the records returned, I get the CITY and the number of records there are for that CITY.
Thanks in Advance.
Phil