| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Extracting Parent Model from Nested Sets Model
When i foresaw it would work i forgot about completing the query to
get what was actually wanted... So here it is for mysql:
SELECT @parent_left = 33; //Change these to fit your needs SELECT @parent_right = 102;
SELECT @next_brother:=@parent_left;
SELECT @next_brother:=
CASE WHEN left >= @next_brother
THEN right+1
ELSE @next_brother
Nuncanada
nuncanada_at_ig.com.br (Flavio Botelho) wrote in message news:<de0df942.0301202104.9bb8e47_at_posting.google.com>...
> As i had seen an outer join as the only suggestion out there i
> wondered if there weren´t a faster query for tables with a lot of
> nested sets.
>
> This is for mysql, but seems to be translatable to other dbs(?):
>
> SELECT @next_brother:=33; //<- left + 1 for a specific parent
> SELECT @next_brother:=
> CASE WHEN left >= @next_brother
> THEN right+1
> ELSE @next_brother
> END, name
> FROM categories
> ORDER BY left;
>
> Nuncanada
Received on Tue Jan 21 2003 - 12:23:17 CST
![]() |
![]() |