places_available_fields SELECT SUM(max_people) number_of_available_places
FROM wps_byt_tour_schedule availabilities
INNER JOIN (
select d.the_date from
(
select adddate(%s,t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) the_date from
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4
having the_date between %s and %s
ORDER BY the_date
) d
where DATE(d.the_date) >= DATE(CURDATE())
group by d.the_date
order by d.the_date
) possible_dates ON
(
(possible_dates.the_date > DATE(availabilities.start_date) AND possible_dates.the_date <= DATE(availabilities.end_date))
OR
((availabilities.end_date IS NULL OR availabilities.end_date = '0000-00-00 00:00:00') AND possible_dates.the_date <= DATE(availabilities.start_date)
AND (DATE(availabilities.start_date) BETWEEN '2024-12-11' AND '2026-12-11')
)
)
WHERE 1=1 AND availabilities.tour_id = wps_posts.ID AND (the_date BETWEEN '2024-12-11' AND '2026-12-11')
Unfortunately no results match your search criteria. Please try searching for something else.