Query objects are stringable. You can build the inner query and insert it into the outer query as a string:
Note, if you have any parameters in the inner query, you have to bind them to the outer query.
Code:
$innerQuery->select('id_user, GROUP_CONCAT(t.name) AS concatenated_topics') ->from('#__user_topics') ->join('LEFT', '#__topics AS t', 't.id = id_topic') ->group('id_user');$outerQuery->select('u.id, u.name AS user_name, t.concatenated_topics AS topics') ->from('#__users AS u') ->join('LEFT', '(' . $innerQuery . ') AS t', 't.id_user = u.id');
Statistics: Posted by SharkyKZ — Mon Jun 10, 2024 7:57 pm