title: Getting a Syntax error for the variable after Having Count in MySQL
body: <p>This is the code I was given by my professor: </p>
  
  <pre><code>SELECT fName, lName, NoOfMovies
  FROM Directors D, (
  SELECT dID, COUNT(*) NoOfMovies
  FROM MovieDirectors
  GROUP BY dID
  HAVING COUNT(*) &gt; =500) AS T
  WHERE D.dID = T.dID
  ORDER BY NoOfMovies;
  </code></pre>
  
  <p>The error code for sql is "#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 0, 25' at line 2."
  We are actually just supposed to be learning indexes. Her code is supposed to be correct, yet when I let her know that she has an error, she will not help. I have attempted to rewrite the code: </p>
  
  <pre><code>Select fName, lName, NoOfMovies 
  From Directors D Join moviedirectors MD on (D.dID=MD.dID)
  GROUP by D.dID 
  Having COUNT(*) &gt;=500 As T
  Where D.dID =MD.dID
  ORDER by NoOfMovies;
  </code></pre>
  
  <p>Yet, I am still getting an error that I am not using the correct syntax near the variable T.My error code is: "#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'As T
   Where D.dID =MD.dID
   ORDER by NoOfMovies LIMIT 0, 25' at line 4." I am running this in phpmyadmin. If anyone can help, it would be greatly appreciated. </p>