title: Why MySQL error using table alias on a simple select statement?
body: <p>I'm using phpmyadmin to test out some MySQL queries. I'm trying to write a larger, nested query, which is failing due to an unrecognized table alias, so I'm trying to debug smaller parts of it. However, I'm getting confusing errors when I try to use table aliases sometimes. </p>
  
  <p>Can you explain why some of these queries throw errors?</p>
  
  <p><code>SELECT * FROM table1 AS tablealias1</code> (works)</p>
  
  <p><code>SELECT * FROM table1 GROUP BY userid</code> (works)</p>
  
  <p><code>SELECT * FROM table1 GROUP BY userid AS tablealias1</code> (error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS tablealias1
  LIMIT 0, 25' at line 1 )</p>
  
  <p><code>SELECT * FROM table1 WHERE userid=1</code> (works)</p>
  
  <p><code>SELECT * FROM table1 WHERE userid=1 AS tablealias1</code> (same error as above)</p>
  
  <p><code>(SELECT * FROM table1 WHERE userid=1) AS tablealias1</code> (same error as above)</p>