Counting something from a MYSQL table
#4

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.
PHP код:
SELECT COUNT(Member) AS numMembers FROM User WHERE factionId 8
Alternatively, if you want a list of them all:
PHP код:
SELECT factionIdCOUNT(*) as numMembers FROM User WHERE factionId 0 GROUP BY factionId
Reply


Messages In This Thread
Counting something from a MYSQL table - by PepsiCola23 - 17.11.2016, 09:59
Re: Counting something from a MYSQL table - by JaKe Elite - 17.11.2016, 10:11
Re: Counting something from a MYSQL table - by PepsiCola23 - 17.11.2016, 10:30
Re: Counting something from a MYSQL table - by Vince - 17.11.2016, 10:48
Re: Counting something from a MYSQL table - by PepsiCola23 - 17.11.2016, 12:00

Forum Jump:


Users browsing this thread: 1 Guest(s)