title: Subquery in Mysql
body: <p>I'm trying to count users signin in DB, the problem is to count uniq signin by date. The problem, user can have a multiple signin a day.</p>
  
  <p>For example table Student
  StudentID</p>
  
  <p>Hour
  TypeID = StudentID, Date, Time
  123, 2014-11-11, 00:11:00
  123, 2014-11-11, 00:15:00
  123, 2014-11-11, 00:16:00
  etc.</p>
  
  <p>I'm trying to use this query...</p>
  
  <pre><code>    select count(*) from (
  select '1' from Students s LEFT JOIN Hours h on s.StudentID = h.TypeID
  where s.StudentID = stud.StudentID
  group by h.Date) tmp, Student stud
  where s.LastName = 'TestUser'
  </code></pre>
  
  <p>But subquery shows an error: Unknown column stud.StudentID</p>