I currently have 2 tables in which I need to get data from.
My users table looks like: ID | first_name | last_name | username
My data table looks like: ID | filename | doctorname | viewed
What I need to do match the first name and last name from the users table to the doctor name in the data table and the return the "filename" and "viewed" rows from this.
I can't seem to get the query right for it though. I'm using the active record class with code igniter. Ive also tried to have a separate function that concats the first and last name and returns it but I can't seem to pass that variable to the join section of the query.
$avail = '1';
$this->db->select('*');
$this->db->from("users a");
$this->db->where("username",$username);
$this->db->where('CONCAT(first_name, '.', last_name) AS doctorname', FALSE);
$this->db->join('data b', "doctor name = b.doctorName", "left");
$result = $this->db->get();
// print_r($this->db->last_query());
return $result->result();
Anyone know whats going wrong? Thanks