Search code examples
mysqlmariadbheidisql

MySQL Error Unknown column in 'on clause'


I've tried to join 3 tables: a, b and c.

my current code:

SELECT a.a_id, a.variable1, a.variable2 FROM b
LEFT JOIN a ON a.a_id = b.a_id
LEFT JOIN c ON c.c_id = b.c_id
WHERE  a.variable1 IN ('1', '4');

now I get

"Unknown column 'a.id' in 'on clause'".

but I'm not sure how I can avoid this error.

I'm a major beginner so please lots of explanation


Solution

  • Maybe this is the cause:

    LEFT JOIN a ON a.a_id = b.a_id
    

    should probably be

    LEFT JOIN a ON a.a_id = b.b_id
    

    and (?)

    LEFT JOIN c ON c.c_id = b.b_id