SELECT
aff.translationId,
aff.title,
aff.img_icon,
aff.img_icon2
FROM
all_filters_filters aff
WHERE
aff.lang = 'ru'
AND aff.pid = 18
AND EXISTS (
SELECT 1
FROM products_colors pc
JOIN all_filters_filters_items affi ON affi.pid = pc.pid_with
WHERE
pc.pid IN (244258, 245440, 326452, 87960, 87968, 88372, 88598, 88606, 243686)
AND affi.fid = aff.translationId
)
ORDER BY
aff.heading_contact ASC
SELECT
aff.translationId,
aff.title,
aff.img_icon,
aff.img_icon2
FROM
all_filters_filters aff
WHERE
aff.lang = 'ru'
AND aff.pid = 2
AND EXISTS (
SELECT 1
FROM products_colors pc
JOIN all_filters_filters_items affi ON affi.pid = pc.pid_with
WHERE
pc.pid IN (244258, 245440, 326452, 87960, 87968, 88372, 88598, 88606, 243686)
AND affi.fid = aff.translationId
)
ORDER BY
aff.heading_contact ASC
SELECT
aff.translationId,
aff.title,
aff.img_icon,
aff.img_icon2
FROM
all_filters_filters aff
WHERE
aff.lang = 'ru'
AND aff.pid = 3
AND EXISTS (
SELECT 1
FROM products_colors pc
JOIN all_filters_filters_items affi ON affi.pid = pc.pid_with
WHERE
pc.pid IN (244258, 245440, 326452, 87960, 87968, 88372, 88598, 88606, 243686)
AND affi.fid = aff.translationId
)
ORDER BY
aff.heading_contact ASC
SELECT
aff.translationId,
aff.title,
aff.img_icon,
aff.img_icon2
FROM
all_filters_filters aff
WHERE
aff.lang = 'ru'
AND aff.pid = 1
AND EXISTS (
SELECT 1
FROM products_colors pc
JOIN all_filters_filters_items affi ON affi.pid = pc.pid_with
WHERE
pc.pid IN (244258, 245440, 326452, 87960, 87968, 88372, 88598, 88606, 243686)
AND affi.fid = aff.translationId
)
ORDER BY
aff.heading_contact ASC