Welcome Guest, Not a member yet? Register   Sign In
selecting from multiple tables
#2

[eluser]TheFuzzy0ne[/eluser]
I wonder if this will work any better:

Code:
$this->db->select('a.title, a.desc, b.title AS cat_title, b.desc AS cat_desc');
         ->from('products a');
         ->join('categories b', 'products.category_id=categories.id', 'INNER');
         ->where('a.category_id', 'b.id');

$res = $this->db->get();

I'm not entirely sure about this but you might need to move the call to $this->db->select() to under the from and join calls. I seem to recall that CodeIgniter had a problem with tracking alias', but I am not certain that I recall correctly.


Messages In This Thread
selecting from multiple tables - by El Forum - 05-24-2009, 12:44 PM
selecting from multiple tables - by El Forum - 05-24-2009, 12:58 PM
selecting from multiple tables - by El Forum - 05-24-2009, 01:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB