您如何在子查询中引用父查询列?这是我的查询
SELECT
c.username, c.staff_of, CONCAT(c.first_name, ' ', c.middle_name, ' ', c.last_name ) AS csr,
d.date, d.account, d.total_transaction, d.total_participate, d.total_amount,
(SELECT COUNT(id) FROM users WHERE created_by = c.username ) AS total_agents
FROM `users` c,
(SELECT
DATE(res_date) AS date, B.res_account AS account,
COUNT(B.res_id) AS total_transaction,
COUNT(DISTINCT(B.res_account)) AS total_participate,
SUM(B.res_amount) AS total_amount
FROM
merchant_responses B
WHERE B.res_account IN (SELECT t.staff_of FROM users t WHERE t.created_by = c.username)
) AS d
WHERE c.account_type ='DSO' GROUP BY c.username
这就是我得到的结果
#1054 - Unknown column 'c.username' in 'where clause'
如何使 c.username 在子查询中可见?
提前感谢