I'm working with a dataset in MySQL that includes a hierarchy column with formats like:
1
1.A
1.A.1
1.A.1.a
1.A.1.b
1.A.2
1.A.2.a
1.B.1
1.B.1.a
2
2.A
...
I'd like to build a table with a self-referencing key to the parent (the last value before the most recent dot) by parsing this out on the fly in a SELECT. Is there a way to do this in MySQL or will I need to use an external script?
SUBSTRING_INDEX()orREGEXP_SUBSTR()to extract the part of the string before the last.