我堆叠了一个我无法实现的查询,并且没有弄清楚问题,
SELECT * FROM sites AS s
INNER JOIN sites_authors AS s_aut ON s_aut.site_id = s.site_id
INNER JOIN authors AS aut ON aut.author_id = s_aut.author_id
INNER JOIN author_trans AS trans ON trans.lang_iso = aut.lang_iso
LEFT JOIN (
countries_authors AS c_aut
INNER JOIN zones AS z ON z.zone_id = c_aut.zone_id
AND z.code = aut.code
INNER JOIN carriers_zones AS cz ON cz.zone_id = z.zone_id
AND cz.site_id = s.site_id
INNER JOIN carriers AS cr ON cr.carrier_id = cz.carrier_id
AND cr.active = 1
)
ON c_aut.lang_iso = trans.lang_iso
我得到的错误是'on clause'中的未知列'aut.code'
以及'on子句'中的未知列's.site_id'
但是,当我用具体值替换这些列时,不会发生错误。
它是php-mysql项目中的查询
答案 0 :(得分:0)
You can use like this
SELECT * FROM sites AS s
INNER JOIN sites_authors AS s_aut ON s_aut.site_id = s.site_id
INNER JOIN authors AS aut ON aut.author_id = s_aut.author_id
INNER JOIN author_trans AS trans ON trans.lang_iso = aut.lang_iso
LEFT JOIN (
SELECT * FROM countries_authors AS c_aut
INNER JOIN zones AS z ON z.zone_id = c_aut.zone_id
INNER JOIN carriers_zones AS cz ON cz.zone_id = z.zone_id
INNER JOIN carriers AS cr ON cr.carrier_id = cz.carrier_id
AND cr.active = 1
) t
ON t.lang_iso = trans.lang_iso AND t.code = aut.code AND t.site_id = s.site_id;