Hi
There is the way to me.
If you hire me, I will make class-isleaf structure.
In other words, we need to make a table with class-isleaf hierarchy.
<id, title, class, isleaf>
If then, you will use it easily without self-function.
I have 14+ years of experiences in MySQL and data structure.
Please hire me.
Thanks
Regarding my skill, please check following query
SELECT id, GROUP_CONCAT(res SEPARATOR ' ' ) AS result FROM
(SELECT id, field1, lowcase, CONCAT(UPPER(SUBSTR(lowcase,1,1)),SUBSTR(lowcase,2, LENGTH(lowcase)-1)) res
FROM(
SELECT
id,
SUBSTRING_INDEX(
SUBSTRING_INDEX(field1, ' ', n),
' ',
-1
) AS field1,
LOWER(SUBSTRING_INDEX(
SUBSTRING_INDEX(field1, ' ', n),
' ',
-1
)) lowcase
FROM tablea
JOIN (SELECT 1 AS n
UNION SELECT 2 AS n
UNION SELECT 3 AS n
UNION SELECT 4 AS n
UNION SELECT 5 AS n
UNION SELECT 6 AS n
UNION SELECT 7 AS n
UNION SELECT 8 AS n
UNION SELECT 9 AS n
UNION SELECT 10 AS n) numbers
ON CHAR_LENGTH(field1)
- CHAR_LENGTH(REPLACE(field1, ' ', ''))
>= n - 1) tbl
ORDER BY id
) tblB
GROUP BY id