Welcome Guest, Not a member yet? Register   Sign In
how codeigniter join two tables to have both Id columns
#1

I want to join two tables that I have both Id columns in join table by codeigniter. I want both id column from comment and users tables.
I write below code

Code:
$this->db->select('users.name as user_full_name, users.id as userid', false);
   $this->db->from('users');

   $this->db->select()
       ->from('comment')
       ->where('project_id', $projectId)
       ->where('user_id', $user_id)
       ->join('users', 'comment.user_id_from =userid')
       ->order_by("comment.id", "asc");
   return $this->db->get()->result_array();

but face error, I do not know why

error:

Code:
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM (users, comment) JOIN users ON comment.user_id_from =userid W' at line 1

SELECT users.name as user_full_name, users.id as userid, * FROM (users, comment) JOIN users ON comment.user_id_from =userid WHERE project_id = '3' AND user_id = '84' ORDER BY comment.id ASC

please show me how to solve it
Reply


Messages In This Thread
how codeigniter join two tables to have both Id columns - by hamid3d - 03-27-2019, 03:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB