gpt4 book ai didi

php - Yii2模型搜索查询让商店在周一和周五开门

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

我想编写 Yii2 模型搜索查询以使商店在周一和周五开业。

下面是表结构和查询

shop_name  openday 
------------------------
shop-A Monday
shop-A Tuesday
shop-A Wednesday
shop-A Thursday
shop-A Friday
shop-B Monday
shop-B Tuesday


SELECT shop_name
FROM availability WHERE openday IN ('Monday', 'Friday')
GROUP BY shop_name HAVING COUNT(*) = 2;

我想实现此查询 yii2 模型搜索,

$query->andWhere("(`parking_availability`.`day` IN('Monday', 'Friday'))")->groupBy('parking_availability.day')->having('COUNT(*) = 2');

以上查询不起作用请帮助我...

最佳答案

试试这个:

$query->andWhere(['in', 'day', ['Monday', 'Friday']])
->groupBy('openday')
->having('COUNT(shop_name) = 2');

关于php - Yii2模型搜索查询让商店在周一和周五开门,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43329636/

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