Mysql filter json data value range

This one is bit complicated than sinmple range in mysql , my field data is {"id":"15","value":"1200"} and I can find it by ,

FROM  `my_table` 
WHERE  `my_field` 
REGEXP  '{"id":"15","value":"1200"}'

but what I need is the range for the value

so I need to look for range between 1000 > 2000 and field with json value 1200 should match. I cant redo the output with php because it will eat up the resource , so please if it is possible within Mysql without me processing the data trough php on return

any help is appreciated!


LC gave us very nice solution

REGEXP '{"id":"15","value":"(1[0-9][0-9][0-9]|2000)"}'


My knee-jerk reaction is to say "stop storing more than one value in a single column", but if you have to do it that way and you have regex power, use it (untested):

FROM `my_table` 
WHERE `my_field` REGEXP '{"id":"15","value":"(1[0-9][0-9][0-9]|2000)"}'

Keep in mind, there's no way to optimize this query using indexes so you are stuck with examining every row in my_table.

Need Your Help

Angularjs ng-repeat radio button list: selected radio returning undefined value

angularjs radio-button undefined angularjs-ng-repeat

I have found a lot of people with the same question but the answers given don't work for me.