Deco <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > My will is to return the areas in some cascade order... I can do it > recursively, but it generates too many queries. I was wondering how i could > do this with only one query to the database. > > Here's the structure i have so far: > AREAS (area_id INT; parent_id INT; root_id(??) INT; description > VARCHAR(60)); >
Hello, I've come across this type of thing for link categories/subcategories. Heres how I solved it: Table Structure: cat_id INT; parent_id INT; desc VARCHAR(255); sort_id INT; Example rows: 1 0 Computers 1 2 1 Hardware 2 3 2 Modems 3 4 1 Software 4 Take a look at the sort_id field. Now, to get all the categories & subcategories I just sort all records by sort_id ASC. This however requires severe maintenance when adding/deleting records. Hope this helped. Charade. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]