title: SQL for a many to many relationship using inner joins
body: <p>I have the following many-to-many relationship between employees and workgroups:</p>
  
  <pre>
  employees table
  -----------------
  id
  
  empgroups table
  ---------------
  employee_id
  workgroup_id
  
  workorders table
  ----------------
  workgroup_id
  </pre>
  
  <p>I'm trying to write SQL that will list all the workorders for an employee based on the workgroups that employee belongs to.</p>
  
  <p>This is my attempt:</p>
  
  <pre><code>SELECT wonum, workgroup_id
  FROM workorders
  INNER JOIN employees
  ON workorders.employee_id = employee_id
  INNER JOIN empgroups 
  ON employees.employee.id = empgroups.employee_id
  WHERE employee_id = 2
  </code></pre>
  
  <p>The error I get is:</p>
  
  <pre><code>ERROR:  schema "employees" does not exist
  </code></pre>
  
  <p>Sorry - the employee has id not employee.id</p>