Please help I need to get rows in the 2 tables with the foreign key poiting to table_a as seen on picture. I have tried Joining this way,
x
SELECT * FROM table_a
INNER JOIN table_b
ON table_a.id = table_b.my_col
INNER JOIN table_c
ON table_a.id = table_c.my_col
but it return empty results. Please help me to fix such SQL JOIN statement
PLEASE LOOK AT THE PHOTO I MADE WHICH SHOW THESE TABLES AND MORE ELABORATION
Advertisement
Answer
could be that you have not valid match in table_b and table_c (your id for table_a don’t match values in table_b and table_c)
try use left join
SELECT *
FROM table_a
LEFT JOIN table_b ON table_a.id = table_b.my_col
LEFT JOIN table_c ON table_a.id = table_c.my_col