title: Codeigniter active record query with concat as join parameter
body: <p>I currently have 2 tables in which I need to get data from.</p>
  
  <p>My users table looks like:
  ID   | first_name   | last_name  |  username</p>
  
  <p>My data table looks like:
  ID |   filename  |   doctorname  |  viewed</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <pre><code>  $avail = '1';
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from("users a");
      $this-&gt;db-&gt;where("username",$username);
      $this-&gt;db-&gt;where('CONCAT(first_name, '.', last_name) AS doctorname', FALSE);
  
  
      $this-&gt;db-&gt;join('data b', "doctor name = b.doctorName", "left");
  
      $result = $this-&gt;db-&gt;get();
      // print_r($this-&gt;db-&gt;last_query());
      return $result-&gt;result();
  </code></pre>
  
  <p>Anyone know whats going wrong?
  Thanks</p>