Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: bosswhite on November 01, 2018, 04:53:21 PM

Title: Database query to return locations of members
Post by: bosswhite 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.
Title: Re: Database query to return locations of members
Post by: Arantor on November 01, 2018, 05:02:24 PM
SELECT country_flag, COUNT(country_flag) AS number FROM smf_members GROUP BY country_flag;
Title: Re: Database query to return locations of members
Post by: bosswhite on November 01, 2018, 05:23:03 PM
Thank you very much for the swift response Arantor. It worked a treat.