gpt4 book ai didi

php - 如何根据其他行中相似或相反的数据选择一行?

转载 作者:可可西里 更新时间:2023-11-01 07:35:48 25 4
gpt4 key购买 nike

id    player_id nat nt_caps
13740 28664 97 24
13741 28664 68 0
13742 28664 79 0
16252 42904 15 40
16253 42904 68 0
16254 42904 241 0

这就是我的 table 的样子。我想为每个 nat 选择具有 nt_caps =“0”的 player_id,或者为 nat =“68”选择具有 nt_caps !=“0”的 player_id。

我尝试使用的 SQL 查询是:

SELECT player_id FROM x WHERE nat = '68' AND (nat != '68' AND nt_caps = '0')

但后来我得到了 player_id '42904' 和 '28664',因为它们都有 1 个匹配查询的条目,但我不想要它们,因为它们有另一个 nat 的 nt_caps 而不是 nat“68”。

我希望你能理解我努力实现的目标。

最佳答案

SELECT * FROM x WHERE nt_caps = 0 OR (nt_caps != 0 AND nat = 68)

关于php - 如何根据其他行中相似或相反的数据选择一行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9268142/

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