title: Unknown table in field list even though table definitely exists
body: <p>I am trying to join 3 tables together but I keep getting 'unknown table 'calls' in field list.  I know the table 'calls' exists</p>
  
  <p>This works...</p>
  
  <pre><code>$sql = "SELECT * FROM calls WHERE id = '$diary_id'";
  </code></pre>
  
  <p>but this doesn't...</p>
  
  <pre><code>$sql = "SELECT * FROM (SELECT calls.id AS calls_id, calls.assigned_user_id AS assigned_user) calls
  RIGHT JOIN accounts on accounts.parent_id = accounts.id
  LEFT JOIN users on assigned_user = user.id
  WHERE calls_id = '$diary_id'";
  </code></pre>
  
  <p>I am trying to use aliases because the tables I am trying to join have the same field names (an inherited database I have to use).</p>
  
  <p>Any help will be greatly appreciated</p>