Re: Child and parent rows On 27 Sep, 09:42, "Joćo Morais" <jcsmor...@gmail.com> wrote:
> > 1 - a111 I presume
>
> You're right, my mistake.
>
> > What is the curent query you're using?
>
> SELECT DISTINCT mi1.id, mi1.idParent, mi1.name, mi1.position
> FROM menuitens AS mi1
> LEFT JOIN menuitens mi2 ON mi1.id=mi2.idParent AND mi2.idMenu=1
> WHERE mi1.idMenu=1
>
> That will provide the following:
>
> id | idParent | name | position
>
> 5 0 a 1
> 9 13 a111 1
> 10 5 a2 2
> 11 5 a3 3
> 12 5 a1 1
> 13 12 a11 1
> 14 0 b 2
>
> When what i want is something like:
>
> id | idParent | name | position
>
> 5 0 a 1
> 12 5 a1 1
> 13 12 a11 1
> 9 13 a111 1
> 10 5 a2 2
> 11 5 a3 3
> 14 0 b 2
Why are you using that query rather than the one that Rik pointed you
to? |