A Tip in codeigniter to join two tables have same coloum name id
$this->ci->db->select("users.*", FALSE); $this->ci->db->select("user_profile.*", FALSE); $this->ci->db->from("users"); $this->ci->db->join("user_profile", "user_profile.user_id = users.id",'inner'); $this->ci->db->where(array('users.id'=>$user_id), NULL, FALSE);
Users table has id and other table User_profile have id and user_id now users's id and user_profile's user_id have a foreign key relationship. user_id from User_profile is foriegn key of users'id . Therefore both entries in different tables are same i.e. user_profile's user_id amd users's id are same. You will receieve an array like this with ofcourse more fields. ID and User_ID is merged into user_id and id of array contains id of user_profile table. now
example:
[id] => 34 [user_id] => 41