I've got two tables, where one holds several id's as pipe-separated string and another that holds names for each id. I want to concat the names as one-liner string with \n between the names.
Tables:
Id-table
| StringIds |
'1|2|3|4|5|4|1'
Name-table
| StringId | String Name |
1 'One'
2 'Two'
3 'Three'
4 'Four'
5 'Five'
I've tried with following code without any success:
SELECT GROUP_CONCAT(StringName || '\n')
FROM Names
WHERE
StringId
IN
(
SELECT DISTINCT
GROUP_CONCAT(REPLACE(StringIds,'|',','))
FROM Ids
) ORDER BY StringName ASC
Expected output: 'One'\n'Two'\n'Three'\n'Four'\n'Five'\n
Aucun commentaire:
Enregistrer un commentaire