Yeah I understand what he wants, but the problem boils down to the project with no parent. The only thing I can suggest is if you have a dummy row in, so the "top" parent row, (1) or (6) in my example with have the dummy as its parent. Then using: select b.id parentID, b.name parentName, a.id childID, b.name childName from tbl_project a, tbl_project b where b.id = a.parent and a.id = 1 Should give a row of: ParentID: 0 ParentName: Dummy ChildID: 1 ChildName: Project One So, if a Project has a parent that the name is called Dummy, then you know it doesn't have a parent. HTH. C. -----Original Message----- From: Mark Rees [mailto:mrees@xxxxxxxxxxxxxxxxx] Sent: 26 July 2005 13:39 To: php-general@xxxxxxxxxxxxx Subject: Re: MySQL + PHP question ************************************* This e-mail has been received by the Revenue Internet e-mail service. ************************************* "André Medeiros" <andre.caum@xxxxxxxxx> wrote in message news:1122379553.3499.14.camel@xxxxxxx > One thing I didn't quite explain myself well... I'm building this to > register objects on a permission system. > > The SQL weight is heavy as it is, and I want to save queries as much as > possible. Making two queries to extract information about a project and > it's parent is not something I'd want to do. I know recursiveness, but > thanks for the pointers and for the reply :) > > Best regards I must admit I still don't really get what you are looking for. Does this query help? select c.field1 AS childfield1, c.field2 AS childfield2, (etc) p.field1 AS parentfield1, p.field2 AS parentfield2, (etc) FROM child AS c LEFT JOIN parent AS p ON c.parent=p.id ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ************************ This message has been delivered to the Internet by the Revenue Internet e-mail service ************************* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php