title: Codeigniter Many to Many Error
body: <p>I have 3 tables ...</p>
  
  <p>instructors, classes and instructor_teach</p>
  
  <p>I want to display a list of classes that the instructor teaches</p>
  
  <p>I have been using tutorials and the like to try and work this out so if my code is messy i do apologize. </p>
  
  <p>Model...</p>
  
  <pre><code>function getMemberPrograms($id){
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('instructor_teach');
      $this-&gt;db-&gt;join('instructor_teach', 'instructors.id = instructor_teach.instructor_id');
      $this-&gt;db-&gt;join('classes', 'instructor_teach.program_id = classes.id');
      $this-&gt;db-&gt;where('instructor_teach.instructors_id', $id);
      return;
  }
  </code></pre>
  
  <p>In the controller i just have a print_r statement to see what the results are but at the moment i am getting </p>
  
  <blockquote>
    <p>Error Number: 1066</p>
    
    <p>Table/alias: 'instructor_teach' non unique</p>
  
  <pre><code>SELECT * FROM (`instructor_teach`, `classes`) JOIN `instructor_teach`
  ON `instructors`.`id` = `instructor_teach`.`instructor_id` JOIN
  `classes` ON `instructor_teach`.`program_id` = `classes`.`id` WHERE
  `instructor_teach`.`instructors_id` = '1'
  </code></pre>
    
    <p>Filename: C:/wamp/www/fitness/application/models/members_model.php</p>
    
    <p>Line Number: 16</p>
  </blockquote>
  
  <p>what i want is an array that has all the information from the classes the instructor teaches so </p>
  
  <p>instructor 1 teaches class 1, class 2</p>
  
  <p>array would return </p>
  
  <p>class 1.name
  class 1.description</p>
  
  <p>class 2.name
  class 2.description</p>
  
  <p>etc..</p>
  
  <p>I hope this makes sense as i am still getting to terms with this</p>
  
  <p>Many Thanks
  Joe </p>