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');
More Related Contents:
- MySQL – How to unpivot columns to rows?
- SQL Performance UNION vs OR
- Combining UNION and LIMIT operations in MySQL query
- Using union and order by clause in mysql
- How would I use ON DUPLICATE KEY UPDATE in my CodeIgniter model?
- INSERT INTO SELECT statement with more columns which is not in another table
- How can I make SQL case sensitive string comparison on MySQL?
- ‘IF’ in ‘SELECT’ statement – choose output value based on column values
- 1052: Column ‘id’ in field list is ambiguous
- Count the occurrences of DISTINCT values
- Codeigniter – multiple database connections
- Why does MySQL allow “group by” queries WITHOUT aggregate functions?
- SQL: selecting rows where column value changed from previous row
- Cast int to varchar
- SQL query of multiple values in one cell
- Import SQL file into mysql
- MySQL SELECT last few days?
- How to skip certain database tables with mysqldump?
- “where 1=1” statement [duplicate]
- MySQL error 1241: Operand should contain 1 column(s)
- How to transpose rows to columns with large amount of the data in BigQuery/SQL?
- Is there a way to get the row number in Mysql like the rownum in oracle [duplicate]
- How to get a list of months between two dates in mysql
- My SQL Dynamic query execute and get ouput into a variable in stored procedure
- Postgres LEFT JOIN with WHERE condition
- How to format number with “.” as thousands separator and “,” as decimal separator?
- Using DISTINCT and COUNT together in a MySQL Query
- How to check if field is null or empty in MySQL?
- Update multiple rows with multiple ‘where’ clauses for each individual row
- ORDER BY alphabet first then follow by number