small query problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

small query problem

Post 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
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: small query problem

Post 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.
Post Reply