title: sub-query not accessing parent query alias
body: <pre><code>SELECT *,
  `batch`.`batch_id` as `batchId`,
  `batch`.`center_id` as `centerId`,
  `batch`.`scheme_id` as `schemeId`,
  `batch`.`batch_start_date` as `BatchStartDate`,
  (SELECT COUNT(`attendance_count`) AS `eligible_for_assessment` FROM 
       (SELECT COUNT(`mark_attendance`) AS `attendance_count` FROM `dailyattendance` 
        WHERE `mark_attendance`="p" AND `scheme_id`=`schemeId` AND `batch_id`=`batchId`
        AND `center_id`=`centerId` GROUP BY `candidate_id`) AS `sfkjsd`
        WHERE `attendance_count` &gt; 6
  )
  from `batch`
  </code></pre>
  
  <p>in this sub-query it return error, "Unknown column 'schemeId' in 'where clause'". in mysql sub-query accessing parent parameters in 3rd level of sub-query?</p>
  
  <pre><code>(SELECT COUNT(`attendance_count`) AS `eligible_for_assessment` FROM 
       (SELECT COUNT(`mark_attendance`) AS `attendance_count` FROM `dailyattendance` 
        WHERE `mark_attendance`="p" AND `scheme_id`=1 AND `batch_id`=2
        AND `center_id`=3 GROUP BY `candidate_id`) AS `sfkjsd`
        WHERE `attendance_count` &gt; 6
  )
  </code></pre>
  
  <p>this query return me total count of candidate who is present more than 6 days in a month. i need to pass this "<code>schemeId</code>" dynamically from parent select query.</p>
  
  <pre><code>(SELECT COUNT(*) from `enrolment` WHERE
  `enrolment`.`batch_id`=`batchId` AND `enrolment`.`center_id`=`centerId`
  AND `enrolment`.`ew_enrolled_for_scheme`=`schemeId`) as `enrolled_student_count`
  </code></pre>
  
  <p>in this query i am using parent selector <code>schemeId</code> and other and it gives me count in result. but if i place another sub-query inside <code>FROM (SELECT....)</code> in sub-query like above i mention it will give me error.</p>