[eluser]amatotax[/eluser]
Hello ppl, I've tried diffrent solutions, noone works fine :/
My query:
Code:
public function get_accepted_relations($uid)
{
$this->db
->select('users.id uid, relations.*')
->from('users')
->join('relations', 'relations.sender = users.id')
->where(array('users.id' => $uid, 'is_accepted' => 1));
$query = $this->db->get();
if($query->num_rows() > 0)
{
return $query->result();
}
else
{
return FALSE;
}
}
If I put
Code:
->join('relations', 'relations.recipient = users.id')
after first JOIN I'm gettin the following error:
Quote:Error Number: 1066
Not unique table/alias: 'relations'
SELECT `users`.`id` uid, `relations`.* FROM (`users`) JOIN `relations` ON `relations`.`sender` = `users`.`id` JOIN `relations` ON `relations`.`recipient` = `users`.`id` WHERE `users`.`id` = 1 AND `is_accepted` = 1
Filename: /var/www/models/mysite_model.php
Line Number: 89
Even
Code:
->join('relations', 'relations.recipient = users.id', 'LEFT')
seems not working
Without the second JOIN it works perfect! Any ideas dear CI users how to double join the same table?