gpt4 book ai didi

mysql - 如何找到只有男性顾客的商店?

转载 作者:行者123 更新时间:2023-11-29 09:53:00 25 4
gpt4 key购买 nike

我有这个架构:

人员(姓名、性别)

频率(名称、商店)

我的问题是,如何找到顾客全部为男性的商店?

最佳答案

您可以将 GROUP BYHAVING 结合使用:

SELECT frequents.shop
FROM frequents LEFT JOIN person ON frequents.name = person.name
GROUP BY frequents.shop
HAVING SUM(person.sex = 'female') = 0 AND SUM(person.sex = 'male') > 0

demo at dbfiddle.uk

关于mysql - 如何找到只有男性顾客的商店?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54459497/

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