mysql - Show tree result between two table related with comma -


in mysql table1 is

id name parent 1  1   0 2  2   1 3  3 1 

and table2 is

id name parent 1  com    2,3 -->is table1.id 

i want relate between table2.parent , table1.id , show tree result :

com -> 1 -> two,three 

how can query it? query this:

select  * table1 left join table1 b on b.parent=a.id b.id in (2,3) 

this work nice didn't work this:

select  * table1 left join table1 b on b.parent=a.id b.id in (select parent table2) 

try this:

select * table2 t2 left join table1 t1 on find_in_set(t1.id, t2.parent) > 0 group t2.id ; 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -