mysql - Get field from first table by foreign key from second -


two tables: categories, , many-to-many relations:

categories id | name 1    first 2    second 3    third  relations parent | child 1        2 1        3 

how can result?:

first | second first | third 

i can

select c.name, r.child  categories c  left join relations r on c.id = r.parent 

and result is

first | 2 first | 3 

so, how can child name in table?

select c1.name, c2.name relations r left join categories c1 on r.parent = c1.id left join categories c2 on r.child = c2.id c1.id = 1 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -