如何从子查询中的子查询中最顶层的父查询中获取列?我必须像传递变量一样传递它吗?这是我的密码:
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
我得到的回答是“错误代码:1054。“where子句”中的未知列“c.in\u customer\u id”
1条答案
按热度按时间8e2ybdfx1#
原则上,您希望将子查询移到
FROM
条款。试试这个。。。