Essayez :
mysql> SELECT -> GROUP_CONCAT( -> CONCAT_WS('|||', 0, 1, -> GROUP_CONCAT(CONCAT_WS('|', 2, 3) SEPARATOR '||') -> ) -> ) `test`;ERREUR 1111 (HY000):Utilisation invalide du groupe functionmysql> SELECT -> GROUP_CONCAT( -> CONCAT_WS('|||', 0, 1, -> (SELECT GROUP_CONCAT(CONCAT_WS('|', 2, 3) SÉPARATEUR '||')) -> ) -> ) `test`;+-------------+| essai |+-------------+| 0|||1|||2|3 |+-------------+1 ligne dans l'ensemble (0,00 sec)
MISE À JOUR
Une option possible :
mysql> DROP TABLE IF EXISTS `parts`, `labor`, `kits`;Requête OK, 0 lignes affectées (0.00 sec)mysql> CREATE TABLE `kits` ( -> `id` int(11 ) NOT NULL AUTO_INCREMENT, -> `kit_id` int(11) DEFAULT NULL, -> `is_quote` tinyint(4) NOT NULL DEFAULT '0', -> `name` varchar(45) DEFAULT NULL, -> `description` varchar(150) DEFAULT NULL, -> `quantity` varchar(45) DEFAULT NULL, -> PRIMARY KEY (`id`), -> UNIQUE KEY `id_UNIQUE` (`id`), -> KEY `KIT` (` kit_id`) > ); Requête OK, 0 lignes affectées (0.00 sec)mysql> CREATE TABLE `labor` ( -> `id` int(11) NOT NULL AUTO_INCREMENT, -> `kit_id` int(11) DEFAULT NULL, -> `is_quote` tinyint(4) NOT NULL DEFAULT '0', -> `description` varchar(150) NOT NULL, -> `hours` varchar(45) NOT NULL DEFAULT '0', -> PRIMARY KEY (` id`), -> UNIQUE KEY `id_UNIQUE` (`id`), -> KEY `KIT` (`kit_id`) -> );Requête OK, 0 lignes affectées (0.00 sec)mysql> CREATE TABLE `parts` ( -> `id` int(11) NOT NU LL AUTO_INCREMENT, -> `kit_id` int(11) DEFAULT NULL, -> `is_quote` tinyint(4) NOT NULL DEFAULT '0', -> `name` varchar(45) DEFAULT NULL, -> `description` varchar( 150) DEFAULT NULL, -> `sale_price` varchar(45) DEFAULT '0.00', -> `quantity` varchar(45) NOT NULL, -> PRIMARY KEY (`id`), -> UNIQUE KEY `id_UNIQUE` (` id`), -> KEY `KIT` (`kit_id`) -> );Requête OK, 0 lignes affectées (0.00 sec)mysql> INSERT INTO `kits` -> (`id`, -> `kit_id`, -> `is_quote`, -> `name`, -> `description`, -> `quantity`) -> VALUES -> (1,0,0,"Main Kit", "Sample Description",1);Query OK , 1 ligne affectée (0.00 sec)mysql> INSERT INTO `kits` -> (`id`, -> `kit_id`, -> `is_quote`, -> `name`, -> `description`, -> `quantity `) -> VALUES -> (2,1,0,"Kit dans le kit", "Description de l'échantillon",1);Requête OK, 1 ligne affectée (0.00 sec)mysql> INSERT INTO `parts` -> (`kit_id `, -> `is_quote`, -> `name`, -> `description`, -> `sale_price`, -> `quantity`) -> VALUES -> (1,0,"First Kit Part", "Part description","23.5",1);Requête OK, 1 ligne affectée (0.00 sec)mysql> INSERT INTO `parts ` -> (`kit_id`, -> `is_quote`, -> `name`, -> `description`, -> `sale_price`, -> `quantity`) -> VALUES -> (2,0,"Kit dans la partie du kit 1", "Description de la pièce d'échantillon","23.5",1);Requête OK, 1 ligne affectée (0.00 sec)mysql> INSERT INTO `parts` -> (`kit_id`, -> `is_quote`, -> `name`, -> `description`, -> `sale_price`, -> `quantity`) -> VALUES -> (2,0,"Kit dans la partie 2 du kit", "Description de la pièce échantillon","23.5" ,1);Requête OK, 1 ligne affectée (0.00 sec)mysql> INSERT INTO `labor` -> (`kit_id`, -> `is_quote`, -> `description`, -> `hours`) -> VALUES -> (1,0,"First Kit labor","1.5");Requête OK, 1 ligne affectée (0.00 sec)mysql> INSERT INTO `labor` -> (`kit_id`, -> `is_quote`, -> ` description`, -> `heures`) -> VALEURS -> (2,0,"Kit dans la main-d'œuvre du kit 1","1,5");Requête OK, 1 ligne affectée (0,00 sec)mysql> INSERT INTO `labor` -> (`kit_id`, -> `is_quote`, -> `description`, -> `hours`) -> VALUES -> (2,0,"Kit dans le kit de travail 2 ","1.5");Requête OK, 1 ligne affectée (0.00 sec)mysql> SELECT kits.id, kits.is_quote, -> GROUP_CONCAT( -> CONCAT_WS('|||', kits_table.id, kits_table.name, -> (SELECT GROUP_CONCAT( -> CONCAT_WS('|', parts.id, parts.name) -> SEPARATOR '||') FROM parts WHERE parts.kit_id =kits_table.id), -> (SELECT GROUP_CONCAT( -> CONCAT_WS('|', labor.id, labor.description) -> SEPARATOR '||') FROM labor WHERE labor.kit_id =kits_table.id) -> ) -> SEPARATOR '||||' -> ) as kits , -> GROUP_CONCAT(CONCAT_WS('|', parts.id, parts.name) SEPARATOR '|||') en tant que parties, -> GROUP_CONCAT(CONCAT_WS('|', labor.id, labor.description) SEPARATOR '| ||') as labour -> FROM kits -> LEFT JOIN kits as kits_table ON kits_table .kit_id =kits.id -> LEFT OUTER JOIN parts ON parts.kit_id =kits.id -> LEFT OUTER JOIN labor ON labor.kit_id =kits.id -> WHERE kits.id =1 -> GROUP BY kits.id\ G**************************** 1ère ligne ****************** ******** id :1is_quote :0 kits :2|||Kit dans le kit|||2|Kit dans le kit partie 1||3|Kit dans le kit partie 2|||2|Kit dans le kit de main-d'œuvre 1||3|Kit dans le kit main-d'œuvre 2 pièces :1|Premier kit pièce main-d'œuvre :1|Premier kit main-d'œuvre1 rangée dans l'ensemble (0,00 seconde)
MISE À JOUR 2
mysql> SELECT kits.id, kits.is_quote, -> GROUP_CONCAT(DISTINCT -> CONCAT_WS('|||', kits_table.id, kits_table.name, -> (SELECT GROUP_CONCAT(DISTINCT -> CONCAT_WS ('|', parts.id, parts.name) -> SEPARATOR '||') FROM parts WHERE parts.kit_id =kits_table.id), -> (SELECT GROUP_CONCAT(DISTINCT -> CONCAT_WS('|', labor. id, travail.description) -> SEPARATOR '||') FROM travail WHERE travail.kit_id =kits_table.id) -> ) -> SEPARATOR '||||' -> ) as kits, -> GROUP_CONCAT(DISTINCT CONCAT_WS( '|', parts.id, parts.name) SEPARATOR '|||') en tant que parts, -> GROUP_CONCAT(DISTINCT CONCAT_WS('|', labor.id, labor.description) SEPARATOR '|||') en tant que travail -> FROM kits -> LEFT JOIN kits as kits_table ON kits_table.kit_id =kits.id -> LEFT OUTER JOIN parts ON parts.kit_id =kits.id -> LEFT OUTER JOIN labor ON labor.kit_id =kits.id -> WHERE kits.id =1 -> GROUP BY kits.id\G*************************** 1. rangée *************** ************ id :1is_quote :0 kits :2|||Kit dans le kit|||3|Kit dans la partie 1 du kit||4|Kit dans la partie 2 du kit|||3| Kit dans le kit main-d'œuvre 1||4|Kit dans le kit main-d'œuvre 2 pièces :1|Premier kit, partie 1|||2|Premier kit, partie 2, main-d'œuvre :1|Premier kit, main-d'œuvre 1|||2|Premier kit, main-d'œuvre 21 rangs définir (0,00 s)