gpt4 book ai didi

mysql - 带条件过滤查询

转载 作者:行者123 更新时间:2023-11-29 10:45:35 27 4
gpt4 key购买 nike

我有一张这样的 table

Assigned_job|Assignedbyuser|Approve

8999 |co-admin1 |0

8888 |co-admin2 |1

7777 |co-admin3 |0

现在如果我只想获得 Approve = 1
我可以简单地使用

where Approve = 1

我会得到这个结果

Assigned_job|Assignedbyuser|Approve
8888 |co-admin2 |1

如果我想得到

only Approve=1 but if Assignedbyuser='co-admin1' don't check Approve =1

最终结果应该是这样的

Assigned_job|Assignedbyuser|Approve
8999 |co-admin1 |0
8888 |co-admin2 |1

最佳答案

ANDOR 条件的组合:

WHERE
(AssignedByUser <> 'co-admin1' AND Approve = 1)
OR (AssignedByUser = 'co-admin1')

关于mysql - 带条件过滤查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44644091/

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