views:

43

answers:

2

I don't spend a whole lot of time in MySQL, but I have been asked to look into a problem with my church's website. It has been down for quite some time and I am trying to get it back up and running. The original site was done in Mambo 4.5.3, which is an old version. I will upgrade it at some point, but I just want to get it running for the time being.

I am currently having a problem with the Mambo built in query below. Wherever the site administration tries to access pages, I get the error message:

Unknown column 'c.access' in 'on clause'.

I have verified that the column does exist in the specified table. Now I am stumped. I opened up the MySQL Query analyzer and pasted the query in and I get the same error message with code 1054. Does anyone have any ideas?

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
+5  A: 
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 
RedFilter
haha, just finished typing out the same thing
Joe Martinez
+1: Or group joins with parentheses
Mchl
@RedFilter @Joe Worked like a charm. Thanks!
Jason Watkins
A: 

The error 1052 message text is actually something like Column 'foo' in %s is ambiguous. It normally happens when you join tables that have columns with the same name and you refer to them without the table prefix.

:-?

Álvaro G. Vicario