Welcome Guest, Not a member yet? Register   Sign In
Select from two different tables with same fieds name
#1
Question 

Hi everybody,
so excited for my first post on this forum Big Grin.

I am Trying to implement a select and join using the Active Record class from two tables, conversations and users, where conversations.user = users.id.

So I compose the query on this way:

$this->db->from('conversations');
$this->db->where('recipients',$id);
$this->db->join('users', 'conversations.user = users.id');
$query = $this->db->get();
return $query->result();

The result is fine I get all the row I need, but, problems comes when I use the data on the view, cause after that if I try to print the conversation id I get the user id instead.

<?= $message->id ?> --> Here is the user id instead of the conversation id.

Looks like the last id replaces the first  Undecided .

Can somebody show me ho to compose the query for getting both the two ids but with different identifier ?
So I may get them on my view writing something like that:

<?= $message->id ?> <?= $message->iduser ?>

limailmirino  Cool
Reply


Messages In This Thread
Select from two different tables with same fieds name - by limailmirino - 03-05-2015, 04:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB