ON子句中的另一个未知列名称错误

时间:2012-08-11 07:20:42

标签: mysql join

查询:

SELECT  c.title AS title
            , c.introtext AS body
            , c.state AS state
            , c.created AS created
            , c.created_by AS uid
            , c.modified AS modified
            , c.modified_by AS modified_uid
            , c.published AS published
            , c.published_by AS published_uid
            , jos_categories.title AS category
FROM
          jos_content AS c, jos_categories
INNER JOIN jos_categories AS jc
ON c.sectionid = jc.section
WHERE c.sectionid = 7

我确定sectionid列存在,但我收到错误:

  

错误代码:1054。'on'中的未知列'c.sectionid'   条款'0.000秒

我看到了这个主题:MySQL unknown column in ON clause但我也解决不了。

2 个答案:

答案 0 :(得分:1)

将您的FROM子句更改为:

FROM   jos_content AS c
INNER JOIN jos_categories AS jc 
ON c.sectionid = jc.section 
WHERE c.sectionid = 7 

答案 1 :(得分:0)

您在jos_categoriesjos_categories AS jc之间执行联接:

jos_content AS c, jos_categories
INNER JOIN jos_categories AS jc
ON c.sectionid = jc.section

cjos_content ...