View Single Post

   
  #5 (permalink)  
Old 02-28-2008, 11:28 AM
Rik Wasmus
 
Posts: n/a
Default Re: Child and parent rows

On Wed, 26 Sep 2007 20:04:40 +0200, Joćo Morais <jcsmorais@gmail.com>
wrote:

> Im having a couple of troubles trying to solve the following problem,
>
> CREATE TABLE IF NOT EXISTS menuitens (
> id int(11) NOT NULL auto_increment,
> idMenu int(11) NOT NULL default 0,
> idParent int(11) NOT NULL default 0,
> position int(11) NOT NULL default 0,
> PRIMARY KEY (id)
> ) TYPE=INNODB;
>
> With this I will have a tree structure with rows ordered by position
> field example:
>
> position - field name
>
> 1 - a
> 1 - a1
> 1 - a11
> 1 - a11

1 - a111 I presume
> 2 - a2
> 1 - a21
> 3 - a3
> 4 - a4
> 1 - a41
> 2 - a42
>
> ...
>
> Although I can select every rows I cannot order them by position field
> and keep the "parent-child" grouping, can any one help on this?


What is the curent query you're using? As long as you have an order by
clause detailing "ORDER BY t1.position, t2.position, t3.position" etc...
in the previous example for every level of your tree everything should be
OK.
--
Rik Wasmus
Reply With Quote