I have data which is of type json in mysql and column name is 'student_data'. student_data:
{
"STUDENT_HISTORY": [
{
"regno": "12345678",
"UPDATE_DATE_UNIX_TIME": "65667"
},
{
"regno": "12345332",
"UPDATE_DATE_UNIX_TIME": "654333"
}
]
}
I need to extract student_data based on condition where regno = "12345678" and here I have only regno value don't know index in json and I have tried json_extract query also which is given below.
SELECT JSON_EXTRACT(student_data,"$.STUDENT_HISTORY.regno")
FROM student table
WHERE STUDENT_HISTORY.regno = "12345678"
If you are running MySQL 8.0, you can use
json_table()
: