I want to extract only city values from the below given data structure using Oracle SQL query.
Ex: {"firstName":"Curtis","lastName":"C Fugatt","street1":"4146 Audiss Rd.","street2":null,"city":"Milton"}
PS: The function: json_value is not working and other threads are suggesting solution in Python. I want to use SQL only.
With sample data you posted, one option might be this:
What does it do?
substrfinds the 1st position of thecitystring and adds 7 to it (to skipcityitself, double quotes and the colon sign) and - as a result - returns everything to the end of the stringregexp_replaceremoves anything but alphanumerics and spacesAs you changed your mind (so that
cityisn't the last information in the string), one option might be a nestedSUBSTR: