如何SELECT
在第三级子查询中使用顶级列?
我试过了,但它给出了:unknown column foo.id
SELECT foo.id,
(
SELECT SUM(bar.amount)
FROM bar
JOIN (
SELECT DISTINCT ding.id
FROM baz
JOIN ding ON ding.baz_id = baz.id
WHERE baz.foo_id = foo.id
) AS j ON j.id = bar.id
) AS amount
FROM foo