CodeIgniter Forums
Run Left Join With Using - 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: Run Left Join With Using (/showthread.php?tid=43476)



Run Left Join With Using - El Forum - 07-12-2011

[eluser]Unknown[/eluser]
I need to run this statement with Active Record, but I do not know how to use:
Code:
SELECT a.id, a.desc
FROM table1 a
B LEFT JOIN table2 USING (id)
WHERE IS NULL b.id



Run Left Join With Using - El Forum - 07-12-2011

[eluser]CodeIgniteMe[/eluser]
Code:
$this->db->select('a.id, a.desc')
->from('table1 a')
->join('table2 b','a.id=b.id')
->where('is null b.id')

Also take note, old-style/traditional join is better than the joins available now simply because, not all SQL driven databases support/ has the same syntax of joins, and all (theoretically) SQL driven databases support old-style/traditional joins


Run Left Join With Using - El Forum - 07-12-2011

[eluser]jmadsen[/eluser]
Fine to use Active Record, but why do you feel you need it?

http://ellislab.com/codeigniter/user-guide/database/examples.html