There is such a table, which is a tree table of contents:
CREATE TABLE "tree" ( "Id" INTEGER NOT NULL, "Name" TEXT NOT NULL, "Parent" INTEGER, "SortKey" INTEGER NOT NULL, CONSTRAINT "Id" UNIQUE ("Id") ); INSERT INTO "tree" VALUES (1, 'ะขะตะบัั1' , null, 1); INSERT INTO "tree" VALUES (2, 'ะขะตะบัั2' , null, 0); INSERT INTO "tree" VALUES (3, 'ะขะตะบัั3' , null, 1); INSERT INTO "tree" VALUES (4, 'ะขะตะบัั1.1', 1 , 2); INSERT INTO "tree" VALUES (5, 'ะขะตะบัั1.2', 1 , 1); INSERT INTO "tree" VALUES (6, 'ะขะตะบัั3.1', 3 , 0); Where the Parent field is a link to the "parent" entry. If it is NULL , then the entry is in the root. Tell me, please, what kind of query you can display this table of contents in a sorted form.
Option 1
Ordering in adjacent records ("descendants" of the same "parent") follows the Name field:
1, 'ะขะตะบัั1' , null, 1 4, 'ะขะตะบัั1.1', 1 , 2 5, 'ะขะตะบัั1.2', 1 , 1 2, 'ะขะตะบัั2' , null, 0 3, 'ะขะตะบัั3' , null, 1 6, 'ะขะตะบัั3.1', 3 , 0 Option 2
Sorting in adjacent records ("descendants" of one "parent") follows the SortKey field:
2, 'ะขะตะบัั2' , null, 0 1, 'ะขะตะบัั1' , null, 1 5, 'ะขะตะบัั1.2', 1 , 1 4, 'ะขะตะบัั1.1', 1 , 2 3, 'ะขะตะบัั3' , null, 1 6, 'ะขะตะบัั3.1', 3 , 0 I understand that the requests should in fact be identical - the only difference is in the sort field. Led so for completeness.