我对以下查询有疑问:
{thistable}.id IN (
SELECT id
FROM fab_booking_slots AS slots
WHERE id = '{fab_booking___book_starttime_raw}'
OR NOT EXISTS (
SELECT id +1 FROM (
SELECT taken.book_date, slots.*, count(taken.book_date) AS nbre
FROM fab_booking_taken AS taken
CROSS JOIN fab_booking_slots AS slots
WHERE NOT ((slots.heuredepart_resa < taken.book_end
AND slots.heurearrivee_resa > taken.book_start))
AND DATE(taken.book_date) = DATE('{fab_booking___book_bookingdate}')
GROUP BY slots.id) AS x
WHERE nbre = (
SELECT count(taken.book_date)
FROM fab_booking_taken AS taken
WHERE taken.book_date = x.book_date)
)
)
Order BY id ASC
此查询应返回已存在于数据库中的下拉列表中的值,如果它们是可用的插槽,则返回可用的插槽。
当我独立运行2 SELECT时,它们正在工作。
我很欣赏这里的一些专业知识,因为我无法找到理由并且被卡住了。
此主题遵循以下主题:
可以在那里下载表格。
提前感谢您的支持。
干杯,
马克