17.11.2016, 10:48
You may want to check my tutorial on association tables in my sig. This is useful if a player can be a member of more than one faction, or if only a small fraction of the total players is a member of a faction. In the latter case you avoid cluttering the player's table with null values.
Counting rows is done using the COUNT() aggregate function. Very, very simple.
Alternatively, if you want a list of them all:
Counting rows is done using the COUNT() aggregate function. Very, very simple.
PHP код:
SELECT COUNT(Member) AS numMembers FROM User WHERE factionId = 8;
PHP код:
SELECT factionId, COUNT(*) as numMembers FROM User WHERE factionId > 0 GROUP BY factionId;