gpt4 book ai didi

php - mysql case语句

转载 作者:行者123 更新时间:2023-11-29 05:43:30 24 4
gpt4 key购买 nike

我可以在 mysql case 语句中使用'AND'吗

例如:

$d = $mysqli->query("SELECT id_timeslot, date_book, id_beautician

,coalesce(thera_b, 'available') AS thera_b

FROM ( SELECT t.id_timeslot, p.id_beautician, b.date_book

, MAX(CASE b.id_beautician WHEN 2 THEN 'booked' THEN 'booked' ELSE NULL END
AND
CASE b.date_book WHEN '2011-01-04' THEN 'booked' ELSE NULL END) AS thera_b

FROM timeslot as t
LEFT JOIN bookslot as b ON b.id_timeslot = t.id_timeslot
LEFT JOIN beautician as p ON p.id_beautician = b.id_beautician
GROUP BY t.id_timeslot) AS xx");

或任何其他解决方案?

最佳答案

这是你需要的吗?

MAX(CASE WHEN b.id_beautician =2 
AND b.date_book = '2011-01-04' THEN 'booked' END ) AS thera_b

这使用 searched 大小写格式(the docs 中的第二个)并省略了 ELSE NULL,因为这是隐式的。

关于php - mysql case语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4596023/

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