Mysql Operator To Extract Json
“Believe you can and you’re halfway there.” - Theodore Roosevelt
How to search mysql for last month’s data
select * from test where createdDate>=NOW()- INTERVAL 1 MONTH
Mysql operator to extract JSON
In MySQL, the “-»” operator is used to extract a specific value from a JSON object. It is also known as the JSON extract operator.
The operator is used to retrieve the value of a specific key from a JSON object. The “-»” operator returns the value as a string.
For example, consider a JSON object named “person” with the following structure:
{
"name": "John",
"age": 30,
"address": {
"city": "New York",
"state": "NY",
"zip": "10001"
}
}
To extract the value of the “city” key from the “address” object using the “-»” operator, the following SQL statement can be used:
SELECT person->>'$.address.city' as city FROM table_name;
This will return the value “New York” as a string. The “$.” symbol is used to indicate the root of the JSON object and the “-»” operator is used to extract the value of the “city” key.
–End–