![]() |
Cross Join - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: Cross Join (/showthread.php?tid=1282) |
Cross Join - juggernautsei - 02-25-2015 Hi, I have been having a problem with getting cross join to function properly in my project. I need to cross join three tables to produce display results. The model code is this: Code: function immChild() { This query should return on Code: id child immune immun_date id fname lname id name Instead it returns literally a thousand rows. Anyone know what the code should be to cross join three tables? RE: Cross Join - Rufnex - 02-25-2015 On your joins you need the condition as second parameter as described here http://www.codeigniter.com/userguide3/database/query_builder.html?highlight=join As e.g. like this $this->db->join('children as b', 'a.id = b.a_id'); RE: Cross Join - edellascenza - 02-25-2015 When you JOIN a table without any condition, it will bring ALL the dataset within it. RE: Cross Join - aurelien - 02-25-2015 Hi, Be careful, a CROSS JOIN returns all rows without filter (immun rows * immun_master rows * children). Agree with Rufnex. RE: Cross Join - juggernautsei - 02-25-2015 You are absolutely right. I forgot the condition. Now it works right. Code: function immChild() { |