Welcome Guest, Not a member yet? Register   Sign In
Multiple db join on same table
#2

[eluser]aquary[/eluser]
The joining condition is not good (for what the query is for). It'd works only if the news author and the modifier is the same person.

You have to separate the join into two parts.
Code:
$this->db->join('users', 'users.id = news.author', 'left');
$this->db->join('users modified_user', 'modified_user.id=news.modified_by', 'left')

Optionally, you may also have to change the select to choose the name of each person manually.
Code:
$this->db->select('news.*, news.id as news_id, news.created as created_on, users.name as author_name, modifier_users.name as modifier_name');


Messages In This Thread
Multiple db join on same table - by El Forum - 06-21-2011, 02:13 AM
Multiple db join on same table - by El Forum - 06-21-2011, 02:51 AM
Multiple db join on same table - by El Forum - 06-21-2011, 03:01 AM
Multiple db join on same table - by El Forum - 06-21-2011, 03:09 AM
Multiple db join on same table - by El Forum - 06-21-2011, 03:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB