Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need SQL for tree structure
Message
De
28/08/2000 07:24:31
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Need SQL for tree structure
Divers
Thread ID:
00409722
Message ID:
00409722
Vues:
47
Hi All,

MyTable with 3 fields in it viz. code, name, group and has a primary key on code.

group can be blank or have another code and can have a nested level. If it is 0 then it is top level group or it belongs to another top level group.

for example: following data is available
Code	Name	Group
1	XYZ	0
2	ABC	0
3	XXX	1
4	XXY	0
5	XAB	1
6	XAA	2
7	AAA	0
8	AXB	0
9	AYY	4
10	ABA	2
11	AWS	6
12	AWD	6
What I want was to have the above sorted through a SQL query and the output should be like this:
Code	Name	Group
1	XYZ	0
3	XXX	1
5	XAB	1
2	ABC	0
6	XAA	2
11	AWS	6
12	AWD	6
10	ABA	2
4	XXY	0
9	AYY	4
7	AAA	0
8	AXB	0
If you analyse the above output it is something like
	1
		3
		5
	2
		6
			11
			12
		10
	4
		9
	7
	8
Can it be possible with a SQL query?

Thanks in advance.
Répondre
Fil
Voir

Click here to load this message in the networking platform