On子句中的未知列(但确实存在)

时间:2015-04-12 10:02:51

标签: mysql sql

我已经看过其他一些像这样的问题,但我不确定我是否理解/可以在这里应用它。我知道我的数据库有t和w的列,但它也不喜欢。有人可以看看,看看他们是否可以找出问题? :)

错误:'on clause'

中的未知列't.id_cat'
SELECT
            c.id_cat,
            c.cat_name,
            t.id_type,
            t.type_name,
            t.type_desc,
            t.num_works,
            t.num_comments,
            w.id_work,
            t.child_level,
            w.id_member,
            mg.group_name,
            m.real_name,
            w.work_title,
            w.work_cap,
            u.filetype,
            u.location,
            w.id_feedback,
            w.id_series,
            w.id_triggers,
            w.is_adult,
            w.poster_time,
            w.work_comments,
            w.work_views
        FROM
            smf_works_uploads as u
        LEFT JOIN
            smf_works_works AS w ON (w.id_work = u.id_work)
        LEFT JOIN
            smf_members AS m ON (m.id_member = w.id_member)
        LEFT JOIN
            smf_membergroups AS mg ON (mg.id_group = m.id_group)
        LEFT JOIN
            smf_works_categories AS c ON (c.id_cat = t.id_cat)
        LEFT JOIN
            smf_works_types AS t ON (t.id_type = w.id_type)
        WHERE
            t.id_type = 16  

1 个答案:

答案 0 :(得分:4)

切换两个连接

LEFT JOIN
            smf_works_types AS t ON (t.id_type = w.id_type)
LEFT JOIN
            smf_works_categories AS c ON (c.id_cat = t.id_cat)

因为如果您之前已加入表格,则只能使用t