1,105,578 Community Members

self related table problem

Member Avatar
baig772
Junior Poster
165 posts since Mar 2011
Reputation Points: 19 [?]
Q&As Helped to Solve: 11 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi all
I have following table structure

pk_cat_id(int)     cat_name(varchar)     cat_desc(text)    fk_cat_id(int)

table is self related as one to many

i want to select cat_name, cat_desc and parent_cat_name()
i.e.
from fk_cat_id, how i can get cat_name

Member Avatar
smantscheff
Nearly a Posting Virtuoso
1,289 posts since Oct 2010
Reputation Points: 265 [?]
Q&As Helped to Solve: 271 [?]
Skill Endorsements: 8 [?]
 
1
 

Presumably it's

select child.cat_name, child.cat_desc, parent.cat_name
from mytable child, mytable parent
where child.pk_cat_id = parent.fk_cat_id
Question Answered as of 2 Years Ago by smantscheff
Member Avatar
baig772
Junior Poster
165 posts since Mar 2011
Reputation Points: 19 [?]
Q&As Helped to Solve: 11 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks to all
Solved my problem :)

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: