select * from Calendar left join EventCats on EventCats.ID=Calendar.Category left join Locations on Calendar.LocID=Locations.ID left join LocationTypes on Locations.Type=LocationTypes.ID where Calendar.Status != 'I' and EventCats.Status != 'I' and ( cast(Calendar.Repeat as Integer) > 0 or ( date(Calendar.Date) >= date('2022-08-13') and date(Calendar.Date) < date('2022-09-28') ) ) and hits(EventCats.ID,'1,4') > 0 union select * from CalendarFeed left join EventCats on EventCats.ID=CalendarFeed.Category left join Locations on CalendarFeed.LocID=Locations.ID left join LocationTypes on Locations.Type=LocationTypes.ID where CalendarFeed.Status != 'I' and EventCats.Status != 'I' and ( cast(CalendarFeed.Repeat as Integer) > 0 or ( date(CalendarFeed.Date) >= date('2022-08-13') and date(CalendarFeed.Date) < date('2022-09-28') ) ) and hits(EventCats.ID,'1,4') > 0 order by Date,Time,Mod limit 0,199;