Thanks for your replies reddrum & YAOMK,
my tables have associations with one and other..
For example..
Cities field has 2 fields(id, cities), when users register they select a city, and the city is saved in the users table in city field.. which means city has association with the table called: Cities
UserGroups table has a field called 'country' and Users table has a field called country as well, which means Users and UserGroups are related in that field.
I'm trying to list all the cities and number of users who are from that city...
Like I've mentioned before..
New York(12)
Madrid(17)
London(21)
...
Previous query which was posted by reddrum selects 5 fields from UserGroups, uses inner join to see if usergroup has a field called user and checks with user field... but usergroup has ID for users.. and Users table has a groupID field filled with the group ID...
Maybe a proper query might work... but this is just an idea of what I'm seeking..
$query = "SELECT city FROM Cities,
count(*) AS CityCount FROM Cities
WHERE Cities.city IN ( SELECT city FROM Users, Cities WHERE Cities.city = Users.city ) AND ( SELECT country FROM UserGroups WHERE UserGroups.country = Users.country )
GROUP BY `city`
ORDER BY `city` ASC";