How do I build a UNION query with ORDER BY and GROUP BY in Kohana's query builder?
问题 I'm trying to build a UNION query using Kohana's query builder. Everything works fine until I add a GROUP BY or ORDER BY clause. Here is the code I'm using (simplified): $query1 = DB::select('p.name') ->from(array('person', 'p')) ->where('p.organization', 'LIKE', 'foo%') ->limit(10); $names = DB::select('sh.name') ->union($query1, FALSE) ->from(array('stakeholder', 'sh')) ->where('sh.organization', 'LIKE', 'foo%') ->group_by('name') ->order_by('name') ->limit(10) ->execute() ->as_array();