select eventcategories.* from (eventcategories inner join releventcategories on eventcategories.ideventcategory=releventcategories.ideventcategory) inner join releases on releases.idEvent=releventcategories.idEvent where eventcategories.active=1 and releases.active=1 and releases.idSpace=3 and releases.showEnd<=STR_TO_DATE('15/10/2024','%d/%m/%Y') group by eventcategories.ideventcategory order by categoryOrder
SELECT events.idEvent, events.name_102, events.brief_102, events.content_102, events.active, events.link, events.video, events.duration,events.break,pictures.name as picture, releases.showStart,releases.showEnd,releases.customDateText,releases.customDateText_102, releases.promotion, releases.promoStart, releases.promoEnd, releases.promoInhome, releases.code, releases.code_102, releases.externalSale_100, releases.externalSale_102 FROM events INNER JOIN releases ON events.idEvent=releases.idEvent INNER JOIN pictures ON events.idEvent=pictures.idEvent WHERE events.active=1 AND releases.active=1 AND releases.idSpace=3 AND releases.showEnd<=STR_TO_DATE('15/10/2024','%d/%m/%Y') GROUP BY events.idEvent ORDER BY releases.historyOutstanding DESC, releases.showEnd DESC LIMIT 12
SELECT count(events.idEvent) as n FROM events INNER JOIN releases ON events.idEvent=releases.idEvent INNER JOIN pictures ON events.idEvent=pictures.idEvent WHERE events.active=1 AND releases.active=1 AND releases.idSpace=3 AND releases.showEnd<=STR_TO_DATE('15/10/2024','%d/%m/%Y')