Skip to content
Advertisement

Trying to join multiple tables in mysql – get error 1054, Unknown Column

I want to join multiple tables using JOINs, and mysql/mariadb is refusing to find one column. The column exists, of course, and I can’t figure out what the cause might be.

Table Layout

Query: In order to avoid confusion with aliases, I now ran the query with the original table names.

Error Message:

No matter how I restructured my query (foreign key first, primary key first, items table first, categories table first, …, using different JOIN types), I can’t seem to get this to work. Also I read through a whole lot of SO questions to this topic, but I feel that the order is correct, I am not inserting nor updating, and it’s not about quoting. Something is fundamentally broken in my concept, and I’m very keen on learning what this could be.

Advertisement

Answer

Look at your from clause. You reference c.id before you have defined c.

A table cannot be referenced until it is defined in the FROM clause.

You would seem to want:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement