I've got a strange issue when I try to compare values with JSON_EXTRACT.
Here is an extract of my column opening_hours in database :
{"1": {"end": {"max_hour": "1290", "min_hour": "840"}, "begin": {"max_hour": "720", "min_hour": "420"}},
"2": {"end": {"max_hour": "1290", "min_hour": "840"}, "begin": {"max_hour": "720", "min_hour": "420"}},
"3": {"end": {"max_hour": "1290", "min_hour": "840"}, "begin": {"max_hour": "720", "min_hour": "420"}},
"4": {"end": {"max_hour": "1290", "min_hour": "840"}, "begin": {"max_hour": "720", "min_hour": "420"}},
"5": {"end": {"max_hour": "1290", "min_hour": "840"}, "begin": {"max_hour": "720", "min_hour": "420"}}}
When I search if, for example, "720" is between the min_hour and max_hour of each part of the day (begin and end), I've got results :
SELECT *
FROM `service_provider`
WHERE ((JSON_EXTRACT(`opening_hours`, '$."3"."begin"."min_hour"') <= '720'
AND '720' <= JSON_EXTRACT(`opening_hours`, '$."3"."begin"."max_hour"'))
OR (JSON_EXTRACT(`opening_hours`, '$."3"."end"."min_hour"') <= '720'
AND '720' <= JSON_EXTRACT(`opening_hours`, '$."3"."end"."max_hour"')));
====> GOT SOME RESULTS !
But when I do the same thing with "1200", no result found :
SELECT *
FROM `service_provider`
WHERE ((JSON_EXTRACT(`opening_hours`, '$."3"."begin"."min_hour"') <= '1200'
AND '1200' <= JSON_EXTRACT(`opening_hours`, '$."3"."begin"."max_hour"'))
OR (JSON_EXTRACT(`opening_hours`, '$."3"."end"."min_hour"') <= '1200'
AND '1200' <= JSON_EXTRACT(`opening_hours`, '$."3"."end"."max_hour"')));
-----> NO RESULTS.
Yet it is well between "840" and "1290".
I noticed that only numbers before or equal at "720" gave results, so it doesn't take into account the second part of my query (after the OR). Why ? Thank you.