Joining tables with Active Record works fine, but how do I add a WHERE clause into the mix? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Joining tables with Active Record works fine, but how do I add a WHERE clause into the mix? (/showthread.php?tid=15845) |
Joining tables with Active Record works fine, but how do I add a WHERE clause into the mix? - El Forum - 02-16-2009 [eluser]markup2go[/eluser] Hi I'm trying to join tables in my model to gather directly related data of a result. I can join tables just fine like this: Code: // Selects all jobs, adds category join in jobtype columns But now I need to add a where clause into it somehow, on the jobs table only but still joining the other 2. Something like: Code: function get_job(){ This obviously isn't working and I'm pretty frustrated so I figured I would ask and see if anyone can correct me in the right direction. Thanks! Joining tables with Active Record works fine, but how do I add a WHERE clause into the mix? - El Forum - 02-16-2009 [eluser]TheFuzzy0ne[/eluser] id looks ambiguous to me. I'd imagine you'd need to use something like: Code: $this->db->where('jobtypes.id', $this->uri->segment(4)); Code: $this->db->where('categories.id', $this->uri->segment(4)); Joining tables with Active Record works fine, but how do I add a WHERE clause into the mix? - El Forum - 02-16-2009 [eluser]markup2go[/eluser] Thanks, you were exactly right. |