UNION query with codeigniter's active record pattern

strike_noir picture strike_noir · Jan 11, 2010 · Viewed 75.1k times · Source

How to do UNION query with PHP CodeIgniter framework's active record query format?

Answer

Zack picture Zack · Jan 11, 2010

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');