Reputation: 2409
I am trying to make a MySQLi query in PHP to a database that I have full of NHL Players and their projected stats/positions.
This is my query string - my goal is for it to return the top 10 projected goal scorers:
$goalSQL = 'SELECT * FROM players ORDER BY G LIMIT 10';
In my table, G is the column which holds the projected goal count for every player. I also have a column called "Position" which holds the position for every player (G, LW, RW, C, D).
However, I get back an object containing 10 goalies. I am guessing that the SQL is somehow taking my ORDER BY G
to mean order by Position:G
, but in reality I have no clue what is going wrong.
Any ideas? Thanks!
Upvotes: 0
Views: 36
Reputation: 1270401
If I had to guess, goalies have the lowest projected goal count. Try using desc
:
SELECT p.*
FROM players p
ORDER BY p.G DESC
LIMIT 10;
Upvotes: 3