I have a mysql database with table orders
, where all installments are kept in one column called installmentData
example record looks like this:
[
{
"amount": "79.00",
"paid_at": "2019-07-24",
"payment_date": "2019-07-27"
},
{
"amount": "80.00",
"paid_at": false,
"payment_date": "2019-08-27"
},
{
"amount": "80.00",
"paid_at": false,
"payment_date": "2019-09-27"
}
]
What I would like to get is the first record of payment_date
from json where paid_at
is false
I tried something like this
SELECT
JSON_EXTRACT(installmentData, '$[*].paid_at') as paidArray,
JSON_EXTRACT(installmentData, '$[*].payment_date') as dateArray
FROM
orders
WHERE
JSON_CONTAINS(JSON_EXTRACT(installmentData, '$[*].paid_at'), 'false') IS TRUE
AND
resignation IS FALSE
ORDER BY `orders`.`status` DESC
this query return this
["2019-07-24", false, false] ["2019-07-27", "2019-08-27, 2019-09-27]
and I want to only return
[false] ["2019-08-27"]
Is it possible to get that specific value in the example above?