1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
| --------------
SET AUTOCOMMIT = 0
--------------
--------------
START TRANSACTION
--------------
--------------
DROP DATABASE IF EXISTS `base`
--------------
--------------
CREATE DATABASE `base`
DEFAULT CHARACTER SET `latin1`
DEFAULT COLLATE `latin1_general_ci`
--------------
--------------
DROP TABLE IF EXISTS `sabot_oly`
--------------
--------------
CREATE TABLE IF NOT EXISTS `sabot_oly`
( `id` integer unsigned not null primary key,
`model_number` varchar(255) not null,
`compatible_probes` varchar(255) not null,
index `SABOT_IDX` (`model_number`)
) engine=innoDB
default charset=latin1 collate=latin1_general_ci
row_format=compressed
--------------
--------------
insert into `sabot_oly` (`id`,`model_number`,`compatible_probes`) value
(466, 'SA10C-N55S-IHC-NORI...', '10L32-A10'),
(467, 'SA10P-0L 2.25L8', '2.25L8-A10P'),
(468, 'SA10P-0L 5/10L16', '5L16-A10P/10L16-A10P'),
(469, 'SA10P-L38S 2.25L8', '2.25L8-A10P'),
(470, 'SA10P-L38S 5L16', '5L16-A10P'),
(471, 'SA10P-L38S 10L16', '10L16-A10P'),
(472, 'SA10P-N55S 2.25L8', '2.25L8-A10P'),
(473, 'SA10P-N55S 5/10L16', '5L16-A10P/10L16-A10P'),
(474, 'SA10P-N55S-SA 2.25L8', '2.25L8-A10P')
--------------
--------------
select * from `sabot_oly`
--------------
+-----+------------------------+----------------------+
| id | model_number | compatible_probes |
+-----+------------------------+----------------------+
| 466 | SA10C-N55S-IHC-NORI... | 10L32-A10 |
| 467 | SA10P-0L 2.25L8 | 2.25L8-A10P |
| 468 | SA10P-0L 5/10L16 | 5L16-A10P/10L16-A10P |
| 469 | SA10P-L38S 2.25L8 | 2.25L8-A10P |
| 470 | SA10P-L38S 5L16 | 5L16-A10P |
| 471 | SA10P-L38S 10L16 | 10L16-A10P |
| 472 | SA10P-N55S 2.25L8 | 2.25L8-A10P |
| 473 | SA10P-N55S 5/10L16 | 5L16-A10P/10L16-A10P |
| 474 | SA10P-N55S-SA 2.25L8 | 2.25L8-A10P |
+-----+------------------------+----------------------+
--------------
DROP TABLE IF EXISTS `model`
--------------
--------------
CREATE TABLE IF NOT EXISTS `model`
( `id_model` integer unsigned not null primary key,
`model_number` varchar(255) not null,
index `MODEL_IDX` (`model_number`)
) engine=innoDB
default charset=latin1 collate=latin1_general_ci
row_format=compressed
--------------
--------------
insert into `model` (`id_model`,`model_number`) value
(1466, 'SA10C-N55S-IHC-NORI...'),
(1467, 'SA10P-0L 2.25L8'),
(1468, 'SA10P-0L 5/10L16'),
(1469, 'SA10P-L38S 2.25L8'),
(1470, 'SA10P-L38S 5L16'),
(1471, 'SA10P-L38S 10L16'),
(1472, 'SA10P-N55S 2.25L8'),
(1473, 'SA10P-N55S 5/10L16'),
(1474, 'SA10P-N55S-SA 2.25L8'),
(5466, '10L32-A10'),
(5467, '2.25L8-A10P'),
(5468, '5L16-A10P'),
(5471, '10L16-A10P')
--------------
--------------
select * from `model`
--------------
+----------+------------------------+
| id_model | model_number |
+----------+------------------------+
| 5471 | 10L16-A10P |
| 5466 | 10L32-A10 |
| 5467 | 2.25L8-A10P |
| 5468 | 5L16-A10P |
| 1466 | SA10C-N55S-IHC-NORI... |
| 1467 | SA10P-0L 2.25L8 |
| 1468 | SA10P-0L 5/10L16 |
| 1471 | SA10P-L38S 10L16 |
| 1469 | SA10P-L38S 2.25L8 |
| 1470 | SA10P-L38S 5L16 |
| 1472 | SA10P-N55S 2.25L8 |
| 1473 | SA10P-N55S 5/10L16 |
| 1474 | SA10P-N55S-SA 2.25L8 |
+----------+------------------------+
--------------
select s.id as sabot_id,
s.model_number as sabot_model_number,
s.compatible_probes as sabot_compatible_probes,
m1.id_model as model1_id,
m1.model_number as model1_number,
m2.id_model as model2_id,
m2.model_number as model2_number
FROM sabot_oly as s
left outer join model as m1
on m1.model_number = s.model_number
left outer join model as m2
on m2.model_number in (
select substring_index(substring_index(so.Compatible_probes,'/',1),'/',-1) from sabot_oly as so where so.id = s.id union
select substring_index(substring_index(so.Compatible_probes,'/',2),'/',-1) from sabot_oly as so where so.id = s.id union
select substring_index(substring_index(so.Compatible_probes,'/',3),'/',-1) from sabot_oly as so where so.id = s.id union
select substring_index(substring_index(so.Compatible_probes,'/',4),'/',-1) from sabot_oly as so where so.id = s.id union
select substring_index(substring_index(so.Compatible_probes,'/',5),'/',-1) from sabot_oly as so where so.id = s.id union
select substring_index(substring_index(so.Compatible_probes,'/',6),'/',-1) from sabot_oly as so where so.id = s.id union
select substring_index(substring_index(so.Compatible_probes,'/',7),'/',-1) from sabot_oly as so where so.id = s.id union
select substring_index(substring_index(so.Compatible_probes,'/',8),'/',-1) from sabot_oly as so where so.id = s.id
group by id
)
order by s.id, m1.id_model, m2.id_model
--------------
+----------+------------------------+-------------------------+-----------+------------------------+-----------+---------------+
| sabot_id | sabot_model_number | sabot_compatible_probes | model1_id | model1_number | model2_id | model2_number |
+----------+------------------------+-------------------------+-----------+------------------------+-----------+---------------+
| 466 | SA10C-N55S-IHC-NORI... | 10L32-A10 | 1466 | SA10C-N55S-IHC-NORI... | 5466 | 10L32-A10 |
| 467 | SA10P-0L 2.25L8 | 2.25L8-A10P | 1467 | SA10P-0L 2.25L8 | 5467 | 2.25L8-A10P |
| 468 | SA10P-0L 5/10L16 | 5L16-A10P/10L16-A10P | 1468 | SA10P-0L 5/10L16 | 5468 | 5L16-A10P |
| 468 | SA10P-0L 5/10L16 | 5L16-A10P/10L16-A10P | 1468 | SA10P-0L 5/10L16 | 5471 | 10L16-A10P |
| 469 | SA10P-L38S 2.25L8 | 2.25L8-A10P | 1469 | SA10P-L38S 2.25L8 | 5467 | 2.25L8-A10P |
| 470 | SA10P-L38S 5L16 | 5L16-A10P | 1470 | SA10P-L38S 5L16 | 5468 | 5L16-A10P |
| 471 | SA10P-L38S 10L16 | 10L16-A10P | 1471 | SA10P-L38S 10L16 | 5471 | 10L16-A10P |
| 472 | SA10P-N55S 2.25L8 | 2.25L8-A10P | 1472 | SA10P-N55S 2.25L8 | 5467 | 2.25L8-A10P |
| 473 | SA10P-N55S 5/10L16 | 5L16-A10P/10L16-A10P | 1473 | SA10P-N55S 5/10L16 | 5468 | 5L16-A10P |
| 473 | SA10P-N55S 5/10L16 | 5L16-A10P/10L16-A10P | 1473 | SA10P-N55S 5/10L16 | 5471 | 10L16-A10P |
| 474 | SA10P-N55S-SA 2.25L8 | 2.25L8-A10P | 1474 | SA10P-N55S-SA 2.25L8 | 5467 | 2.25L8-A10P |
+----------+------------------------+-------------------------+-----------+------------------------+-----------+---------------+
--------------
COMMIT
--------------
--------------
SET AUTOCOMMIT = 1
--------------
Appuyez sur une touche pour continuer... |
Partager