phpmysqlcodeigniterunionquery-builder

UNION query with CodeIgniter's query builder pattern


How can I do a UNION query with CodeIgniter's query builder methods?


Solution

  • CodeIgniter's ActiveRecord doesn't support UNION, so you would just write your query and use the ActiveRecord's query method.

    $this->db->query('SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2');