gpt4 book ai didi

Mysql Count 忽略 order by

转载 作者:行者123 更新时间:2023-11-30 00:21:59 30 4
gpt4 key购买 nike

我试图在查询中使用 count(t.name) 来计算行数,但是一旦添加 count(t.name) order by 被忽略 - 我仍然得到结果和正确的行数,但顺序错误。

SELECT t.name, t.team_id, count(t.name) as count
FROM st_team t INNER JOIN st_position p
ON t.team_id = p.team_id
WHERE p.league_id = '$league_id'
AND p.type = 'full'
AND p.grid = '0'
ORDER BY t.name
LIMIT 0,1

我想这一定与“t”有关。前缀,但尝试各种组合并没有让我有任何进展。

非常感谢任何帮助,干杯P

最佳答案

如果您需要 Count ,则需要分组依据:

           AND p.grid = '0'
GROUP BY t.name
ORDER BY t.name
LIMIT 0,1

关于Mysql Count 忽略 order by,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23160993/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com