Re: error 1054: Unknown column
I'm getting a similar problem, I don't know if it's related, with my phpBB board. I'm attempting to modify it myself, I have a decent working knowledge of php and (I thought) SQL.
I'm getting the error:
SQL Error : 1054 Unknown column 'f.forum_last_post_id' in 'on clause'
on the query:
SELECT f.*, sf.*, p.post_time, p.post_username, sp.post_time, sp.post_username, u.username, u.user_id, su.username, su.user_id
FROM ((test1_forums f, forums sf
LEFT JOIN test1_posts p ON p.post_id = f.forum_last_post_id LEFT JOIN users u ON u.user_id = p.poster_id)
LEFT JOIN posts sp ON sp.post_id = sf.forum_last_post_id
LEFT JOIN users su ON su.user_id = sp.poster_id)
ORDER BY f.cat_id, f.forum_order, sf.cat_id, sf.forum_order
I have experimented with this query extensively, and I found the error seems to be in my FROM-- when I switch the order to FROM ((forums sf, test1_forums f, I no longer get the error (though it still doesn't work the way I want.) I tried removing and adding parentheses, it did not change the query's output. I have verified that the column in question does indeed exist. If I "split" this query into the "shared" (the sp, su, sf parts) and "unshared" (the aliases without s's), each works fine-- but damned if I can get them to work together.
I have checked and rechecked my syntax and the comma would appear to be correct for the FROM portion of the query. There are many other SQL queries in the phpBB files which appear very similar to this one (multiple tables in from with aliases, in a series with commas, followed by join statements), and they all work fine.
This is driving me up a wall and has been the last three days. Can anyone shed any light on it?