Extracting Parent Model from Nested Sets Model
From: Flavio Botelho <nuncanada_at_ig.com.br>
Date: 20 Jan 2003 21:04:48 -0800
Message-ID: <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.
END, name
FROM categories
ORDER BY left;
Date: 20 Jan 2003 21:04:48 -0800
Message-ID: <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 _at_next_brother:=33; //<- left + 1 for a specific parent
SELECT _at_next_brother:=
CASE WHEN left >= _at_next_brother
THEN right+1
ELSE _at_next_brother
END, name
FROM categories
ORDER BY left;
Nuncanada Received on Tue Jan 21 2003 - 06:04:48 CET
