How can I get a column from the top-most parent query in a subquery within a subquery? Do I have to pass it like a variable? Here's my code:
SELECT c.in_customer_id, 
( 
     SELECT
         group_concat(the_schedule separator '\r\n') 
     FROM
     ( 
         SELECT
             concat_ws('\n', 'Route: ', s.route_id, 'Interval: ', s.service_interval, 'Week No.: ', s.week_no, 'Weekdays: ', s.weekdays, 'Start Date: ', s.start_date, 'End Date: ', s.end_date, 'Start Time: ', s.start_time, 'End Time: ', s.end_time, '\n') AS the_schedule
         FROM
             schedule s 
         WHERE
             s.service_address_id IN 
             ( 
                 SELECT in_customer_address_id 
                   FROM   tbl_customer_address a2 
                  WHERE  a2.in_customer_id = c.in_customer_id
             ) 
             AND s.is_skipped = '0'
         GROUP BY
             s.service_address_id
     ) a
 )
     AS "Schedule"
 FROM
     tbl_customers c
The response I get is "Error Code: 1054. Unknown column 'c.in_customer_id' in 'where clause'"
                        
As a principle, you want to move the sub-queries in to your
FROMclause.Try something like this...