Advertisement:

Author Topic: Database query to return locations of members  (Read 4598 times)

Offline bosswhite

  • Jr. Member
  • **
  • Posts: 204
  • Gender: Male
Database query to return locations of members
« on: November 01, 2018, 04:53:21 PM »
In my database I have a table smf_members

Within that table is a column country_flag

Each user selects from a pulldown menu when registering their country and a small flag of that nation is then shown under their name when posting.

So, within the column country_flag the content varies for each member (e,g. gb us ca etc.)

I want to be able to do a database query that will return the total number of members for each country code so I can determine the breakdown of member's locations.

Any idea how I could achieve that? Any help would be greatly appreciated.
I've been down so long now it's beginning to look like up..

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,492
    • StoryBB/StoryBB on GitHub
Re: Database query to return locations of members
« Reply #1 on: November 01, 2018, 05:02:24 PM »
SELECT country_flag, COUNT(country_flag) AS number FROM smf_members GROUP BY country_flag;
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline bosswhite

  • Jr. Member
  • **
  • Posts: 204
  • Gender: Male
Re: Database query to return locations of members
« Reply #2 on: November 01, 2018, 05:23:03 PM »
Thank you very much for the swift response Arantor. It worked a treat.
I've been down so long now it's beginning to look like up..