Запрос для получения записей о связях, которые действительно существуют (по существу, все дефекты производителя, которые существуют):
select
md.f_manufacturerId, md.f_defectId
from productionlines as md
inner join productionlines as m on m.type="manufacturer" and m.manufacturerId=md.f_manufacturerId
inner join productionlines as d on d.type="defect" and d.defectId=md.f_defectId
where md.type="manufacturerdefect"
order by md.f_manufacturerId
Я хочу ПРОТИВОПОКАЗАТЬ / ОБРАТИТЬ это ... Я хочу знать списокДЕФЕКТ К ВСТАВКАМ ПРОИЗВОДИТЕЛЯ У нас НЕ ИМЕЕТСЯ.
Структура данных ...
ПРОИЗВОДИТЕЛЬ:
{
"name": "Ball Bearings"
"id": "00a4260956d54e46932001d853df843c",
"manufacturerId": 28,
"type": "manufacturer"
}
{
"name": "Wheel Rims"
"id": "3ad4b5c6433d6e8b9c230fdd5dda8b33",
"manufacturerId": 2,
"type": "manufacturer"
}
ДЕФЕКТ:
{
"name": "Bad Drill Bit"
"id": "c348fd358d10023964e45d6590624a00",
"defectId": 7,
"type": "defect"
}
{
"name": "Bad Shipping"
"id": "33b8add5ddf032c9b8e6d3346c5b4da3",
"defectId": 9,
"type": "defect"
}
ДЕФЕКТЫ ПРОИЗВОДИТЕЛЯ:
{
"id": "de426435bd10023964e45d6590624a00",
"f_defectId": 7,
"f_manufacturerId": 2,
"type": "manufacturerdefect"
}
{
"id": "de426435bd10023964e45d6590624a01",
"f_defectId": 9,
"f_manufacturerId": 2,
"type": "manufacturerdefect"
}
{
"id": "de426435bd10023964e45d6590624a02",
"f_defectId": 7,
"f_manufacturerId": 28,
"type": "manufacturerdefect"
}
{
"id": "de426435bd10023964e45d6590624a03",
"f_defectId": 9,
"f_manufacturerId": 28,
"type": "manufacturerdefect"
}
Для ясности, если какой-либо из дефектов производителя выше НЕ СУЩЕСТВУЛ, я хочу знать все комбинации производителей и идентификаторов дефектов, которые отсутствуют.