gpt4 book ai didi

mysql - 同一列的多个值的 AND 子句

转载 作者:行者123 更新时间:2023-11-29 04:16:33 25 4
gpt4 key购买 nike

我该如何修复这个查询?

SELECT COUNT(*)
FROM user_notifications
WHERE notification_status = '0'
AND notification_sent_to = ?
AND notification_category = 'ticket reply'
AND notification_category = 'groupdoc'

我需要计算票据回复和 groupdoc 的结果过滤通知类别。

非常感谢您的帮助。

最佳答案

特定列在给定行中只能有一个值。所以下面的条件永远不可能为真

notification_category = 'ticket reply'AND notification_category= 'groupdoc'

当人们认为我需要值为 'a' 的行 值为 'b' 的行时,实际使用的逻辑运算符是 OR

SELECT COUNT(*) FROM user_notifications WHERE notification_status = '0' AND notification_sent_to=? AND
(notification_category = 'ticket reply' OR notification_category= 'groupdoc')

关于mysql - 同一列的多个值的 AND 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42695160/

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