09.03.2015, 11:28
Main drawback is that you can't sort or group that column and you can't use an index. If you have a lot of data and you need a better overview, consider splitting up one table into multiple tables and link them with 1-on-1 relations. Although it doesn't have to be 1-on-1 because most of time it useful to store extra information.
Let's say you create a table "kills_and_deaths" with fields: victim [int unsigned foreign key references accounts], killer [int unsigned foreign key references accounts], weapon [tinyint unsigned foreign key references weapon_names].
You can then insert a new row each time a kill occurs (in OnPlayerDeath). Then, if you want to find out the amount of deaths for a player you can do:
Or even:
To produce a list of how many times the player was killed by different weapons.
Let's say you create a table "kills_and_deaths" with fields: victim [int unsigned foreign key references accounts], killer [int unsigned foreign key references accounts], weapon [tinyint unsigned foreign key references weapon_names].
You can then insert a new row each time a kill occurs (in OnPlayerDeath). Then, if you want to find out the amount of deaths for a player you can do:
PHP код:
SELECT COUNT(*) FROM kills_and_deaths WHERE victim = %d.
PHP код:
SELECT victim, weapon, count(*) from kills_and_deaths where victim = %d group by victim, weapon