Query Builder Nest Joins at the end of the Query - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Query Builder Nest Joins at the end of the Query (/showthread.php?tid=81628) |
Query Builder Nest Joins at the end of the Query - ElTomTom - 03-30-2022 I'm creating a query with Query Builder for PostgreSQL, my query has tables and joins for each table. It so happens that PostgreSQL requires that joins that use a table must be below it in the Query. Like(example 1). I set up my query in CodeIgniter (example 2), however, it always nests the JOIN at the end, generating an SQL that has an error for PostgreSQL (example 3). How can I fix this without having to create the SQL directly in CodeIgniter? Example 1: Code: SELECT Example 2: PHP Code: $this->db->from('table1 t'); Example 3: Code: SELECT RE: Query Builder Nest Joins at the end of the Query - iRedds - 03-30-2022 It's impossible. In version 4.2, subqueries will become available in the FROM clause. If your query can work through subqueries, then perhaps this will solve your problem. Code: SELECT * FROM (SELECT * FROM t1 JOIN t2) as t3, (SELECT * FROM t4 JOIN t5) as t6 |