oh dear, I seem to do that too often!!
The part you gave me works perfectly. The other bit I had to change was to move two AND clauses up to the joining condition rather than showing them after the WHERE. If I were to leave them after the WHERE, they seem to be ignored.
Code:
SELECT
ps.product_name
, ps.room_type
, pl.start_date
, pl.end_date
, tb.tariffs
FROM product_live AS pl
INNER
JOIN products_stock AS ps
ON ps.id = pl.product_id
inner
JOIN ( SELECT live_product_id
, GROUP_CONCAT(
CONCAT_WS(','
, age_group
, t.tariff
, t.tariff_terms_abbr
, t.currency
, tt.tariff_terms) order by t.tariff asc
SEPARATOR ';' ) AS tariffs
FROM tariffs as t
inner join tariff_terms as tt
on t.tariff_terms_abbr = tt.tariff_terms_abbr
GROUP
BY live_product_id ) AS tb
ON tb.live_product_id = pl.id
and pl.business_id =?
AND pl.priority = 'b'
WHERE
/* first, let's do this one:
start date <= today and end date is >= today */
CURRENT_DATE BETWEEN pl.start_date
AND pl.end_date
OR
/* second, let's do this one:
start date is up to 9 months from today */
pl.start_date BETWEEN CURRENT_DATE
AND CURRENT_DATE + INTERVAL 9 MONTH
bazz
Bookmarks