gpt4 book ai didi

php - Mysql 组查询错误

转载 作者:行者123 更新时间:2023-11-29 08:56:59 25 4
gpt4 key购买 nike

我有一些代码可以从 mysql 获取一组结果,请参见下文,

SELECT string, COUNT(string) as myCount 
FROM ip_stats WHERE string != '' OR string IS NOT NULL
GROUP BY string
ORDER BY myCount DESC
LIMIT 10

现在这段代码工作得很好,但是当我添加另一个 where 子句时,如下所示,它返回相同的结果,并且似乎完全忽略了 where 子句的 member = 部分?

SELECT string, COUNT(string) as myCount 
FROM ip_stats WHERE member_id = '000826' string != '' OR string IS NOT NULL
GROUP BY string
ORDER BY myCount DESC
LIMIT 10

如有任何想法或建议,我们将不胜感激。

最佳答案

您的 where 子句有一些错误:

WHERE member_id = '000826' string != '' OR string IS NOT NULL

应该是

WHERE member_id = '000826' AND (string != '' OR string IS NOT NULL)

关于php - Mysql 组查询错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9692070/

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