MySQl查询问题

时间:2010-08-03 18:09:03

标签: sql mysql mysql-error-1054

我没有花太多时间在MySQL上,但我被要求调查我教会网站的问题。它已经停机了很长一段时间,我试图让它恢复运行。原始网站是在Mambo 4.5.3中完成的,这是旧版本。我会在某些时候升级它,但我只想让它暂时运行。

我目前在下面的Mambo内置查询中遇到问题。无论站点管理员试图访问哪些页面,我都会收到错误消息:

  

'on子句'中的未知列'c.access'。

我已经确认该列确实存在于指定的表中。现在我很难过。我打开了MySQL查询分析器并粘贴了查询,我得到了代码为1054的相同错误消息。有没有人有任何想法?

SELECT 
    c.*, 
    g.name AS groupname, 
    cc.name, 
    u.name AS editor, 
    f.content_id AS frontpage, 
    s.title AS section_name, 
    v.name AS author 
FROM 
    mos_content AS c, 
    mos_categories AS cc, 
    mos_sections AS s 
    LEFT JOIN mos_groups AS g ON g.id = c.access 
    LEFT JOIN mos_users AS u ON u.id = c.checked_out 
    LEFT JOIN mos_users AS v ON v.id = c.created_by 
    LEFT JOIN mos_content_frontpage AS f ON f.content_id = c.id 
WHERE 
    c.state >= 0 
    AND c.catid=cc.id 
    AND cc.section=s.id 
    AND s.scope='content' 
ORDER BY 
    s.title, 
    c.catid, 
    cc.ordering, 
    cc.title, 
    c.ordering 
LIMIT 
    0,10

2 个答案:

答案 0 :(得分:5)

SELECT  
    c.*,  
    g.name AS groupname,  
    cc.name,  
    u.name AS editor,  
    f.content_id AS frontpage,  
    s.title AS section_name,  
    v.name AS author  
FROM  
    mos_content AS c 
    INNER JOIN mos_categories AS cc on c.catid=cc.id  
    INNER JOIN mos_sections AS s on cc.section=s.id 
    LEFT JOIN mos_groups AS g ON g.id = c.access  
    LEFT JOIN mos_users AS u ON u.id = c.checked_out  
    LEFT JOIN mos_users AS v ON v.id = c.created_by  
    LEFT JOIN mos_content_frontpage AS f ON f.content_id = c.id  
WHERE  
    c.state >= 0  
    AND s.scope='content'  
ORDER BY  
    s.title,  
    c.catid,  
    cc.ordering,  
    cc.title,  
    c.ordering  
LIMIT  
    0,10 

答案 1 :(得分:0)

error 1052消息文本实际上类似于Column 'foo' in %s is ambiguous。当您连接具有相同名称的列的表并且您在没有表前缀的情况下引用它们时,通常会发生这种情况。

: -