The app_recurrenceexception column have deleted appointment date.
I achieved this way
SELECT
app_recurrenceexception,
(SELECT GROUP_CONCAT(LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(app_recurrenceexception, ',', numbers.n), ',', -1), 8) SEPARATOR ',')
FROM
(
SELECT 1 + a.N + b.N * 10 + c.N * 100 AS 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) AS a
CROSS JOIN
(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) AS b
CROSS JOIN
(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) AS c
) AS numbers
WHERE
numbers.n <= 1 + (LENGTH(app_recurrenceexception) - LENGTH(REPLACE(app_recurrenceexception, ',', '')))
) AS modified_date
FROM
`bm_appointment`
WHERE
app_eventid = 15;
But I Want simple way of output
SELECT (20240402T073000Z,20240405T073000Z,20240408T073000Z,20240411T073000Z) from bm_appointment
how to split the first 8 words for each comma separated value in MSQL query. How to Extract the date from the above string.
Expected output is
20240402,20240405,20240408,20240411……
2
Answers
There many questions and answer about how split comma separated values in MySql (STRING_SPLIT).
See example with recursion.
Test data
Query
Output is
After grouping (concatenation)