Coba:
mysql> SELECT -> GROUP_CONCAT( -> CONCAT_WS('|||', 0, 1, -> GROUP_CONCAT(CONCAT_WS('|', 2, 3) SEPARATOR '||') -> ) -> ) `test`;ERROR 1111 (HY000):Penggunaan fungsi grupmysql> yang tidak valid -> SELECT -> GROUP_CONCAT( -> CONCAT_WS('|||', 0, 1, -> (SELECT GROUP_CONCAT(CONCAT_WS('|', 2, 3) SEPARATOR '||')) -> ) -> ) `test`;+-------------+| tes |+-------------+| 0|||1|||2|3 |+-------------+1 baris dalam kumpulan (0,00 detik)
PERBARUI
Satu opsi yang memungkinkan:
mysql> DROP TABLE JIKA ADA `parts`, `labor`, `kits`;Query OK, 0 baris terpengaruh (0,00 detik)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`) -> );Kueri OK, 0 baris terpengaruh (0,00 detik)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`), -> KUNCI UNIK `id_UNIQUE` (`id`), -> KUNCI `KIT` (`kit_id`) -> );Kueri OK, 0 baris terpengaruh (0,00 detik)mysql> CREATE TABLE `parts` ( -> `id` int(11) BUKAN 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`), -> KUNCI `KIT` (`kit_id`) -> );Kueri OK, 0 baris terpengaruh (0,00 detik)mysql> INSERT INTO `kit` -> (`id`, -> `kit_id`, -> `is_quote`, -> `name`, -> `description`, -> `quantity`) -> VALUES -> (1,0,0,"Main Kit", "Contoh Description",1);Query OK , 1 baris terpengaruh (0,00 detik)mysql> INSERT INTO `kits` -> (`id`, -> `kit_id`, -> `is_quote`, -> `name`, -> `description`, -> `quantity `) -> NILAI -> (2,1,0,"Kit dalam kit", "Contoh Deskripsi",1);Kueri OK, 1 baris terpengaruh (0,00 detik)mysql> INSERT INTO `parts` -> (`kit_id `, -> `is_quote`, -> `name`, -> `description`, -> `sale_price`, -> `quantity`) -> VALUES -> (1,0,"First Kit Part", "Part description", "23.5",1);Query OK, 1 baris terpengaruh (0,00 detik)mysql> INSERT INTO `parts ` -> (`kit_id`, -> `is_quote`, -> `name`, -> `description`, -> `sale_price`, -> `quantity`) -> VALUES -> (2,0,,"Kit dalam kit bagian 1", "Contoh Deskripsi Bagian",,"23.5",1);Kueri OK, 1 baris terpengaruh (0,00 detik)mysql> INSERT INTO `parts` -> (`kit_id`, -> `is_quote`, -> `name`, -> `description`, -> `sale_price`, -> `quantity`) -> VALUES -> (2,0,,"Kit dalam kit bagian 2", "Contoh Deskripsi Bagian",,"23.5" ,1);Kueri OK, 1 baris terpengaruh (0,00 detik)mysql> INSERT INTO `labor` -> (`kit_id`, -> `is_quote`, -> `description`, -> `hours`) -> VALUES -> (1,0,"First Kit labor","1.5");Kueri OK, 1 baris terpengaruh (0,00 detik)mysql> INSERT INTO `labor` -> (`kit_id`, -> `is_quote`, -> ` description`, -> `jam`) -> NILAI -> (2,0,"Kit dalam kit tenaga kerja 1",,"1,5");Kueri OK, 1 baris terpengaruh (0,00 sec)mysql> INSERT INTO `labor` -> (`kit_id`, -> `is_quote`, -> `description`, -> `hours`) -> VALUES -> (2,0,"Kit dalam kit labor 2 ","1.5");Kueri OK, 1 baris terpengaruh (0,00 detik)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 '|||') sebagai bagian, -> GROUP_CONCAT(CONCAT_WS('|', labor.id, labor.description) SEPARATOR '| ||') sebagai tenaga -> FROM kit -> 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. baris ******************* ******** id:1is_quote:0 kit:2|||Kit dalam kit|||2|Kit dalam kit bagian 1||3|Kit dalam kit bagian 2|||2|Kit dalam kit bekerja 1||3|Kit dalam pengerjaan kit 2 bagian:1|Kit Pertama Pengerjaan sebagian:1|Pekerjaan Kit Pertama1 baris dalam set (0,00 detik)
PERBARUI 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, labor.description) -> SEPARATOR '||') FROM labor WHERE labor.kit_id =kits_table.id) -> ) -> SEPARATOR '||||' -> ) sebagai kit, -> GROUP_CONCAT(DISTINCT CONCAT_WS( '|', parts.id, parts.name) SEPARATOR '|||') sebagai bagian, -> GROUP_CONCAT(DISTINCT CONCAT_WS('|', labor.id, labor.description) SEPARATOR '|||') sebagai tenaga kerja -> 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. baris *************** ************ id:1is_quote:0 kit:2|||Kit dalam kit|||3|Kit dalam kit bagian 1||4|Kit dalam kit bagian 2|||3| Kit dalam persalinan kit 1||4|Kit dalam persalinan kit 2 bagian:1|Kit Pertama Bagian 1|||2|Kit Pertama Bagian 2 persalinan:1|Persalinan Kit Pertama 1|||2|Kit Pertama persalinan 21 baris masuk set (0,00 detik)