gpt4 book ai didi

mysql - 仅当所有状态为 "no"时,如何通过 request_id 选择请求?

转载 作者:行者123 更新时间:2023-11-29 03:51:05 26 4
gpt4 key购买 nike

结果表:

id | request_id | status
1 | 1 | Yes
2 | 1 | Yes
3 | 2 | Yes
4 | 2 | No
5 | 2 | Yes
6 | 3 | No
7 | 3 | No
8 | 3 | No

如何仅在所有状态为“否”(在此示例中为“3”)时按 request_id 选择请求?

最佳答案

一个简单的方法是使用 NOT IN 查找记录(或 NOT EXISTS ):

select *
from mytable
where request_id not in (select request_id from mytable where status = 'Yes');

(如果您想要排除更多状态,请将 where status = 'Yes' 更改为 where status <> 'No'。)

关于mysql - 仅当所有状态为 "no"时,如何通过 request_id 选择请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47867842/

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