How to parse out quoted values from a column with sql
Question
I have a field that has values like this...
s:10:"03/16/1983"; s:4:"Male"; s:2:"No";
I'd like to parse out the quoted values.
its going to be some sort of combination of substr and instr
its the doublequote i have issues finding its position.
i have tried things like select substr(field_value, instr(field_value,'"'),instr(field_value,'"',null,2)) from table where etc
apologies a noob question...
Solution
Here's something that should work (unable to test at the moment):
select substr(substr(field_value, instr(field_value,':')+1, CHAR_LENGTH(field_value)-1),
instr(substr(field_value, instr(field_value,':')+1, CHAR_LENGTH(field_value)-1),':')+1)
Edit: Putting my comment in the answer:
select substr(field_value, instr(field_value,'\"'),CHAR_LENGTH(field_value)-1)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow