Welcome Guest, Not a member yet? Register   Sign In
Join is not behaving as expected.
#1

[eluser]CloakandPigeon[/eluser]
Hello, kind of new here and just wanted to post up an issue I am running into currently. I am attempting a join between an articles and users table so that I can pull the username column instead of printing out an ID number (it isn't very helpful to just have a number when trying to determine who the article belongs to).

I have the following code in my model:

Code:
$this->db->select('articles.*', 'users.*');
  $this->db->from('articles');
  $this->db->order_by('articleID', 'asc');
  $this->db->join('users', 'users.id = articles.userID');
  $query=$this->db->get()->result();
  return $query;

All fields are available to me when I pass it to the view from the articles table, but none of them are available from the users table. I have attempted with the 'left' parameter added as well. Am I using the join command properly?

I am wanting to get a table with columns for everything in articles and added to that I want to be able to pull the username info from the users table.


Messages In This Thread
Join is not behaving as expected. - by El Forum - 02-22-2013, 11:36 AM
Join is not behaving as expected. - by El Forum - 02-22-2013, 04:54 PM
Join is not behaving as expected. - by El Forum - 02-22-2013, 09:45 PM
Join is not behaving as expected. - by El Forum - 02-23-2013, 01:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB