Created
March 22, 2018 16:15
-
-
Save nini/6690a1509db908a0f8ff3f802d09fe31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT T.value FROM ( | |
SELECT DISTINCT TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(t.ingredients, ',', n.n), ',', -1)) value | |
FROM ProductsHaveMetadata t CROSS JOIN | |
( | |
SELECT a.N + b.N * 10 + 1 n | |
FROM | |
(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) a | |
,(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) b | |
ORDER BY n | |
) n | |
WHERE n.n <= 1 + (LENGTH(t.ingredients) - LENGTH(REPLACE(t.ingredients, ',', ''))) | |
ORDER BY value | |
) AS T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment