![]() |
Multiple join question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html) +--- Thread: Multiple join question (/thread-43612.html) |
Multiple join question - El Forum - 07-18-2011 [eluser]webnology[/eluser] Hi all, I have 3 tables, products, revenue and brands. When showing the list of products, I want to show the sum of all prices (revenue table), the name of the brand (linked to the product from the brands table), and some other data from the products table. This is my working code, excluding ther name of the brand, which works fine. Code: $this->db->select('p.*, SUM(r.product_price) as revenue'); This is my trial for adding the brand name, and I can't make it work. Code: $this->db->select('p.*, SUM(r.product_price) as revenue', 'b.*'); Can someone guide me to the solution here? All help is really appreciated. Regards, Michel Multiple join question - El Forum - 07-18-2011 [eluser]bubbafoley[/eluser] your select is wrong Code: $this->db->select('p.*, SUM(r.product_price) as revenue, b.*'); Multiple join question - El Forum - 07-19-2011 [eluser]webnology[/eluser] Oh dear, I should have noticed that :-) But thank you Bubbafoley for the quick response. Appreciate it! |