CodeIgniter Forums
CI 1.7: $db->get() and Join - 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: CI 1.7: $db->get() and Join (/showthread.php?tid=12789)



CI 1.7: $db->get() and Join - El Forum - 10-31-2008

[eluser]Unknown[/eluser]
As like as this post: http://ellislab.com/forums/viewthread/95148/

My code is
Code:
$this->db->select('user_detail.*, industries.name industry_name');
$this->db->from('user_detail');
$this->db->join('industries', 'industries.id = user_detail.industry', 'left');
$query = $this->db->get_where('user_detail', array('userid'=> $userId));
$detail = $query->row();

But I get error because the translated sql is listed below:
Quote:SELECT user_detail.*, industries.name industry_name
FROM (user_detail, user_detail)
LEFT JOIN industries ON industries.id = user_detail.industry
WHERE userid = 'trustock';
Look the line 2, there are two same table name split by comma. The comma is redundant.


CI 1.7: $db->get() and Join - El Forum - 10-31-2008

[eluser]henrihnr[/eluser]
[quote author="Derek Hsu" date="1225466660"]As like as this post: http://ellislab.com/forums/viewthread/95148/

My code is
Code:
$this->db->from('user_detail');

$query = $this->db->get_where('user_detail', array('userid'=> $userId));

[/quote]

notice 2 lines of code above..you've defined table twice..


CI 1.7: $db->get() and Join - El Forum - 11-02-2008

[eluser]Unknown[/eluser]
The same code was ok in 1.6.3.
But it's not work in 1.7.0