Page 1 of 1

small query problem

Posted: Wed Mar 05, 2008 8:03 am
by itsmani1
I am having a query problem

Here is my db structure

PK_ID,title,parent
1,Propery,0
2,Services,0
3,Rent,1
4,House,3

Now I have PK_ID=4 and want to find its name which is House, its parent name which is Rent and then its parent which is Property

I don't know how to make query for it?

any idea

thank you
-dizyn

Re: small query problem

Posted: Wed Mar 05, 2008 10:30 pm
by Ambush Commander
Read http://www.sitepoint.com/article/hierar ... a-database

There's no way to do this, with your current structure, without subqueries or multiple queries.