SELECT n.*, (SELECT MIN(params) FROM %s AS nga INNER JOIN %s AS ng ON ng.id = nga.group_id WHERE nga.news = n.id) AS newsparams FROM %s AS n JOIN %s AS nl ON n.id=nl.news AND nl.locale=:locale WHERE n.status="active" AND nl.locale=:locale AND n.date >= :date_from AND n.date <= :date_to AND ((n.startdate IS NULL OR n.startdate <= CURDATE()) AND (n.starttime IS NULL OR n.starttime <= CURTIME())) AND (n.enddate IS NULL OR n.enddate >= CURDATE()) AND nl.active="1" ORDER BY nl.importance DESC, n.date DESC, nl.time DESC