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

[eluser]blu3ness[/eluser]
I'm trying to do an old fashion select from two tables

in plain SQL it'll prob be something like this

Code:
SELECT a.title, a.desc,b.title as cat_title,b.desc as cat_desc
FROM products a, categories b
WHERE a.category_id = b.id

How would you accomplish this using activerecord?

I tried
Code:
$this->db->select('*')->from('products')->where('category_id',$category_id)->join('categories','products.category_id=categories.id');

which only gets me the first table data and nothing from the second.

Tyvm


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