Blotark Blotark - 12 days ago 6
SQL Question

#1054 - Unknown column in field list

it's my first time to use INNER JOIN

SELECT `xxx_storage.*`, `xxx_foods.*` FROM xxx_storage INNER JOIN xxx_foods ON `xxx_storage.food_id` = `xxx_foods.food_id`


The error I am getting is this:

#1054 - Unknown column 'xxx_storage.*' in 'field list'

Answer

Try removing the back ticks :

SELECT xxx_storage.*,
       xxx_foods.*
FROM xxx_storage
INNER JOIN xxx_foods
 ON xxx_storage.food_id = xxx_foods.food_id

Back ticks are used for MySQL Reserved words , they are used on single columns, not a list of them (*) , so when you are using them to wrap Table.* , MySQL automatically looks at it as a single column .