SELECT `events`.* FROM `events` WHERE (showHome = 1) AND (((channel = "even" AND isOnlineEvent = 1) OR (isOnline = 1))) AND (homeOnlineFrom <= '2015-03-31') AND (homeOnlineTo >= '2015-03-31') ORDER BY `weight` DESC, `date` ASC LIMIT 8SELECT `events`.* FROM `events` INNER JOIN `galleries` ON galleries.eventId = events.id AND galleries.isActive = 1 WHERE (isOnlineEvent = 1) ORDER BY `galleries`.`createdDate` DESC, `galleries`.`views` DESC LIMIT 5