26 lines
1.3 KiB
MySQL
Raw Normal View History

2023-02-02 08:52:11 +01:00
CREATE TABLE `familles2` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`bord_gauche` INT(10) UNSIGNED NOT NULL,
`bord_droit` INT(10) UNSIGNED NOT NULL,
`niveau` INT(10) UNSIGNED NOT NULL,
`nom` VARCHAR(250) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE = 'InnoDB' DEFAULT CHARACTER SET = 'utf8';
INSERT INTO `familles2` (`id`, `bord_gauche`, `bord_droit`, `niveau`, `nom`) VALUES
(1, 1, 44, 1, 'Transport'), (2, 2, 21, 2, 'Aérien'), (3, 3, 4, 3, 'Planeur'), (4, 5, 6, 3, 'Parachute'),
(5, 7, 8, 3, 'Hélico'), (6, 9, 10, 3, 'Fusée'), (7, 11, 12, 3, 'ULM'), (8, 13, 20, 3, 'Avion'),
(9, 14, 15, 4, 'Militaire'), (10, 16, 17, 4, 'Tourisme'), (11, 18, 19, 4, 'Civil'),
(12, 22, 35, 2, 'Terrestre'), (13, 23, 24, 3, 'Vélo'), (14, 25, 26, 3, 'Voiture'),
(15, 27, 28, 3, 'Camion'), (16, 29, 34, 3, 'Moto'), (17, 30, 31, 4, 'Side-car'),
(18, 32, 33, 4, 'Trail'), (19, 36, 43, 2, 'Marin'), (20, 37, 38, 3, 'Planche à voile'),
(21, 39, 40, 3, 'Paquebot'), (22, 41, 42, 3, 'Voilier');
CREATE VIEW arbo AS
SELECT `familles2`.`id` AS `id`,
Concat(CONVERT(Space((`familles2`.`niveau` * 10)) USING utf8mb3),`familles2`.`nom`) AS `arbre`,
`familles2`.`bord_gauche` AS `bord_gauche`,
`familles2`.`bord_droit` AS `bord_droit`,
`familles2`.`niveau` AS `niveau`
FROM `familles2`
ORDER BY `familles2`.`bord_gauche`