Вот пример настройки < /p>
Код: Выделить всё
drop TABLE IF EXISTS testMain;
CREATE TABLE IF NOT EXISTS testMain(
id int(11) NOT NULL auto_increment,
inspectionID int(11) NOT NULL,
lookupIDs varchar(255),
UpdateField text CHARACTER SET UTF8 COLLATE utf8_unicode_ci NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB DEFAULT CHARACTER SET = UTF8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
drop TABLE IF EXISTS testLookup;
CREATE TABLE IF NOT EXISTS testLookup(
id int(11) NOT NULL auto_increment,
ValueField text CHARACTER SET UTF8 COLLATE utf8_unicode_ci NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB DEFAULT CHARACTER SET = UTF8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
insert into testMain (inspectionID, lookupIDs) values (1,"1,2,4"),(2,"3,4"),(3,"2");
insert into testLookup (ValueField) values ('A'),('B'),('C'),('D'),('E'),('F');
select
m.inspectionID,
m.lookupIDs,
(select group_concat(ValueField) from testLookup where id in (m.lookupIDs)) as val
from
testMain as m;
InspectionID
lookupIDs
val
< /thead>
1 < /td>
1,2,3 < /td>
a, b, c < /td>
< /tr>
2
/> 3,4 < /td>
c, d < /td>
< /tr>
3 < /td>
2 < /td>
b < /td>
< /tr>
b < /td>
< /tr>
b < /td>
< /tr>
/> Но это только использует первое значение, поэтому я получаю < /p>
InspectionId < /th>
щиты < /th>
< /br /th>
< /br /th> < /br /th> < /br /th> < /br /th> < /br /th> < /br /th> < /br /th> < /br /th>
< /thead>
1 < /td>
1,2,3 < /td>
< /td>
< /tr>
2 < /td>
< /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> < /td> /> c < /td>
< /tr>
3 < /td>
2 < /td>
b < /td>
< /tr>
< /tbody>
< /table> < /div>
>
Подробнее здесь: https://stackoverflow.com/questions/796 ... ther-query