[英]ORDER sql query is not working as expected
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. 我正在尝试使用PHP对MySQL数据库进行MySQLi查询,而我的NHL Player和他们的预计统计数据/位置都已满。
This is my query string - my goal is for it to return the top 10 projected goal scorers: 这是我的查询字符串-我的目标是返回预期的前10名目标得分手:
$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. 在我的表格中,G是保存每个球员的预计进球数的列。 I also have a column called "Position" which holds the position for every player (G, LW, RW, C, D).
我还有一个名为“ Position”的列,其中包含每个玩家(G,LW,RW,C,D)的位置。
However, I get back an object containing 10 goalies. 但是,我得到一个包含10个守门员的物体。 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. 我猜测SQL会以某种方式使我的
ORDER BY G
表示order by Position:G
,但是实际上我不知道出了什么问题。
Any ideas? 有任何想法吗? Thanks!
谢谢!
If I had to guess, goalies have the lowest projected goal count. 如果我不得不猜测,守门员的预测进球数最少 。 Try using
desc
: 尝试使用
desc
:
SELECT p.*
FROM players p
ORDER BY p.G DESC
LIMIT 10;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.