gpt4 book ai didi

postgresql - PostgreSQL。如何返回用户表中名为 Latifah、Elizabeth 或 Diana 的记录数?

转载 作者:行者123 更新时间:2023-11-29 13:48:30 25 4
gpt4 key购买 nike

我有这个:

SELECT count(*) FROM users
WHERE name = 'Latifah'
AND name = 'Elizabeth'
AND name = 'Diana';

它返回零。怎么了?有没有办法让它更短?

最佳答案

您可以将OR“聚合”到IN 运算符:

SELECT count(*) 
FROM users
WHERE name IN ('Latifah','Elizabeth','Diana');

关于postgresql - PostgreSQL。如何返回用户表中名为 Latifah、Elizabeth 或 Diana 的记录数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44543153/

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