Welcome Guest, Not a member yet? Register   Sign In
please help me write a join.

Hey guys,

I've never really understood how joins work and now I have to do it in CI, I'm even more confused.

I have a table tutorial (with tutID and all the tut info), a table categories (with catID and name) and a table tutorial_categories (with catID and tutID).

I need to get all tutorials (so from the table tutorial) that are in a certain category. But I have to use categories.name in my where, not catID...

I know this is possible with one query, but I just can't figure it out. Can anyone help me out?

edit: this seems to be working:
if($category != 'all')
    $this->db->like('categories.name', $category);
$this->db->join('tutorial_categories', 'tutorial.tutID = tutorial_categories.tutID');
$this->db->join('categories', 'categories.catID = tutorial_categories.catID');
I need the like instead of where because the names are in lowercase, though they can have capitalisation in the database. Or is there a better way of doing this?

Theme © iAndrew 2016 - Forum software by © MyBB