I want to extract data from a json type column to insert them into a table in order to normalize a database.
The JSON type column is called "info" and an example of a record is the following:
[ { "major" : "International business",
"end" : "2007",
"name" : "Annamalai University",
"degree" : "Master Degree",
"start" : "2005", "desc" : ""
},
{ "major" : "Mechanical Engineering",
"end" : "1990",
"name" : "Bharathidasan University",
"degree" : "Bachelor Degree",
"start" : "1990", "desc" : ""
}
]
This is my code:
SELECT id,
(json_array_elements(info)->>'education')::json ->> 'key' AS key1
FROM perfiles
WHERE id = 1252710;
This is the result I want to obtain: table result example
How should I do the query?
Thanks in advance