Search code examples
mysqlmysql-error-1054

INNER JOIN issue


I am getting the following error from this query:

1054 - Unknown column 'sheet_items.color_id' in 'on clause'

select sheet_items.sheet_id, sheet_items.quantity, materials.material, colors.color
from sheet_items, materials
inner join colors
on colors.color_id=sheet_items.color_id
where sheet_items.sheet_id=4 and sheet_items.material_id=materials.material_id

Any ideas? Thanks in advance!


Solution

  • The way you have it structured now, you are trying to inner join Materials with colors, therefore, it does not know what column you are talking about.. try

    select sheet_items.sheet_id, sheet_items.quantity, materials.material, colors.color
    from materials,sheet_items
    inner join colors
    on colors.color_id=sheet_items.color_id
    where sheet_items.sheet_id=4 and sheet_items.material_id=materials.material_id