Есть функция, которая работает корректно:
public function getListEvents($route) {
$max = 10;
$params = [
'max' => $max,
'start' => ((($route['num'] ?? 1) - 1) * $max),
];
return $this->db->row('
SELECT events.id, events.name as event_name, events.country_id, events.description, countries.name as country_name, GROUP_CONCAT(links.link) as links FROM events
JOIN countries ON events.country_id = countries.id
LEFT JOIN links ON events.id = links.event_id
GROUP BY events.id
ORDER BY id DESC
LIMIT :start, :max
', $params);
}
Необходимо добавить получение картинок по аналогии со ссылками, пробую так:
return $this->db->row('
SELECT events.id, events.name as event_name, events.country_id, events.description, countries.name as country_name, GROUP_CONCAT(links.link) as links, GROUP_CONCAT(images.name) as images FROM events
JOIN countries ON events.country_id = countries.id
LEFT JOIN links ON events.id = links.event_id
LEFT JOIN images ON events.id = images.event_id
GROUP BY events.id
ORDER BY id DESC
LIMIT :start, :max
', $params);
Но ссылки и картинки дублируется, подскажите, как правильно составить запрос?