JOIN MySQL Tables -


i have following tables format:

members

 mem_id | mem_name     ------------------      1              2         b       3         c 

project_members

fk_mem_id | meb_parent_id -------------------------     1          0     2          1     3          2 

and require result like:

mem_id | child| parent --------------------------    1          null    2      b         3      c      b 

i tried fail.. idea....?

select pm.*, m1.meb_name child, m2.meb_name parent  members m1 left join members m2  on m1.meb_parent_id = m2.meb_id 

select project_members.fk_mem_id,         a.mem_name child,         b.mem_name parent    project_members         inner join members                 on project_members.fk_mem_id = a.mem_id         left join members b                on project_members.meb_parent_id = b.mem_id  

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -