Two tables: categories, and their many-to-many relations:
categories
id | name
1 first
2 second
3 third
relations
parent | child
1 2
1 3
How can I get this result?:
first | second
first | third
I only can
SELECT c.name, r.child
FROM categories AS c
LEFT JOIN relations AS r ON c.id = r.parent
And result is
first | 2
first | 3
So, how can I get child name in this table?
1 Answer