Alan 42 Multi Review How To Count & Sort Multiple Columns In 1 MySQL Table?

How to count & sort multiple columns in 1 MySQL table? - alan 42 multi review

And so on. Hi, can count only one column in my table but I have the columns 14 below and the same for each record in my database and classified on the basis of whose name is the first

Home Marker 1, 2 Marker Home, scoring 3 Home Marker 4, Marker 5 at home scoring 6 scorer 7, Away 1 Scorer Scorer Scorer Away 2 Away 3 Away 4 Away 5 Away Scorer scorer 6 Away Scorers score 7

There are not 200 entries with some markers and others, I mean, every commentator names for each line and then displays a grand total of, for example, "Dave Jones - 42, Alan X - 34", etc. etc. in a table on the basis of the whole picture. I do not know if this is possible (as I have a separate column for the competition (before), but only 1) I hope I have explained in detail enough

I Contact with PHP and receive data from the MySQL database.

We thank you, if someone can help
Zack

1 comments:

oracle12... said...

What we want is possible, but the pattern is set to s it is difficult and inefficient to do so.
However, you can (I'll call the fields, for example) limit:
Select Player, COUNT (Player) Total
(SELECT 1 `` Home Player Scorer Table
UNION ALL SELECT `Home Marker 2` FROM table
UNION ALL SELECT `1` FROM table Away Scorers
UNION ALL SELECT `Away Scorer 2 'table) PlayerTotals
Player GROUP BY, ORDER BY COUNT (Player) DESC, player;

This gives you a record of the names of the players and punctuation. From here you can use PHP to display to the desired format ( "Alan X - 34"), or you can use CONCAT SQL function to do this - you would in PHP.

If I were you, I would (look better and standardize) schema database. You do not have a field for each score of the game - which is a separate table. For example, consider this scheme:

Game:
Id
Date
Start Time
Miracles

Player:
Id
Name

Game Players:
GameID
Player

Scorers:
Id
GameID
Player
Score Time


Such a system would not only be more efficient and flexible, but easier to handle:
P. Name SELECT COUNT (S. playerId) Total S LAW scorers, players join in S. playerId P = P. Id
GROUP BY S. playerId ORDER BY COUNT (p. playerId) DESC, name P.;
Much cleaner.

Post a Comment