I have 2 Tables ...provision
and tariff
. Table provision
stored related Tariff-IDs as pipe-separated Value. This Query shows me only the first tariff name
sqlfiddle
SELECT
GROUP_CONCAT(tariff_name)
FROM
tariff
WHERE
tariff_id IN(REPLACE('1272|1312|1314', '|', ','))
I want this query use as a Subquery where '1272|1312|1314'
is the joined field from provision
. Just like...
SELECT
provision.id,
provision.tariff_id,
tariff.id,
( SELECT GROUP_CONCAT( tariff_name ) FROM tariff WHERE tariff_id IN(REPLACE (provision.tariff_id, '|', ',' ))) AS tn
FROM
provision
LEFT JOIN tariff ON tariff.id = provision.tariff_id
This is a very old project and refactoring is not an option!