Created
March 1, 2022 18:35
-
-
Save stringsn88keys/e6ae1271410c960867f11e9a98e5997f to your computer and use it in GitHub Desktop.
MySQL to parse multiline pipe delimited strings into returned rows
This file contains 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
<!-- wp:code --> | |
<pre class="wp-block-code"><code> | |
select list.i, | |
substring_index(substring_index( | |
substring_index( | |
substring_index( | |
'9977034 | e9e82737-db8f-44c0-985b-d004788aa91d | 208 | |
3393402 | aa1cbfe0-a66d-44ac-9b66-bd2369c96e52 | 136 | |
3524174 | 490dbaa0-faed-4773-b3c0-4c979e1b07cb | 250 | |
14843139 | c454ac36-422f-4c2c-b989-4476cd271e95 | 85 | |
7410199 | 906d81c3-e286-4f52-ad02-6e26ad0bdd0f | 200 | |
12253800 | 56b40d26-5f51-4e4e-a118-d03a2c79daf5 | 166 | |
14267398 | 3c5aaa25-f3df-4ab7-bf7d-a10e219e635a | 88 | |
4144785 | 1effd98a-5446-4bf0-bd3a-f5a0b94e7b24 | 172', '\n', list.i), | |
'\n', -1), '|', 2), '|', -1) as uuid | |
from (select f.i * 4 + t.i * 2 + o.i + 1 as i | |
from (select 0 as i union select 1) as o -- ones | |
cross join (select 0 as i union select 1) as t -- twos | |
cross join (select 0 as i union select 1) as f -- fours | |
) as list</code></pre> | |
<!-- /wp:code --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment