title: Nested query in From clause syntax and performance
body: <p>I'm having two tables: one for user information, the second for mapping some relation between users (two column table with two ids, from id to id relation)
  I'm trying to find for a specific userid all his users' relations ids (inner select) and then get more info about them by joining to a table which has more info to show.  </p>
  
  <ol>
  <li><p>Given the following error:
  <img src="https://i.stack.imgur.com/qd4Lc.png" alt="phpMyAdmin error">
  <strong>Error: #1064 - You have an error in your SQL syntax; check the manual list that corresponds to your mySQL server version for the right syntax to use near ') AS i Limit 0,30' at line 6</strong><br>
  What wrong with my query?</p></li>
  <li><p>Is this query is okay in terms of performance, or there are other way to do so? </p></li>
  </ol>
  
  <p><strong>Query:</strong>  </p>
  
  <pre><code> SELECT i.*
      FROM 
          ((SELECT uc.contactId
           FROM tbl_users AS u
           JOIN tbl_users_contacts AS uc ON u.Id = uc.userId
           WHERE uc.userId =1) AS contacts_ids JOIN tbl_users AS u 
  ON contacts_ids.contactId = u.Id) AS i;
  </code></pre>
  
  <p><strong>Edit</strong>: Fixed to:</p>
  
  <pre><code>SELECT *
  FROM 
      ((SELECT uc.contactId
       FROM tbl_users AS u
       JOIN tbl_users_contacts AS uc ON u.Id = uc.userId
       WHERE uc.userId =1) AS contacts_ids JOIN tbl_users AS u 
  ON contacts_ids.contactId = u.Id);
  </code></pre>
  
  <p>Don't know why the final As i was a problem, so I ask for question 2 mainly for this post.</p>