0
Events SQL: select *, profiles.name as profile_name from profile_events
inner join profiles on profile_events.profileID=profiles.profileID
inner join profile_media on profile_media.mediaID = profiles.new_profile_pic
inner join companies on profiles.clientID=companies.clientID
inner join client_ad_contracts on companies.clientID=client_ad_contracts.clientID
inner join profile_categories on profiles.profileID=profile_categories.profileID
inner join categories on categories.categoryID=profile_categories.categoryID
where profiles.active = '1' and (companies.regionID = '' or client_ad_contracts.second_city = '1') and
profiles.region <> '1' and
profile_events.display_start_date <= '2024-10-07' and profile_events.display_end_date >= '2024-10-07' and profiles.clientID <> '0' and profile_events.pending = '0'
and client_ad_contracts.start_date <= '2024-10-07' and date_add(date_add(client_ad_contracts.start_date, INTERVAL client_ad_contracts.contract_term MONTH), INTERVAL client_ad_contracts.extend MONTH) >= '2024-10-07'
order by event_date asc, rand() limit 4