If i have json like the following in a column in a mysql database
[
{
"name": "John",
"checked": true
},
{
"name": "Lucy",
"checked": false
}
]
how can I select in mysql all rows where in the same object name = 'John' and checked = true.
The json objects may have more keys and keys may not be in a specific order.
Just use JSON_CONTAINS:
SELECT * from `users`
WHERE JSON_CONTAINS(`data`, '{"name": "John","checked": true}');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With