如何编写MySQL where子句以查找JSON字段中存在的值

时间:2019-05-29 21:16:43

标签: mysql json

我有一个表名User with Availability列,并且具有JSON数据类型MySQL版本7.2。我想选择星期一具有可用性且开始等于3的那些行,我尝试使SQL WHERE可用性->'$。day.monday'=“ Monday”和可用性->'$。day.monday.start'= 3;流动。 但它不起作用。我可以在selectability->'$。day.monday [*]之类的select中选择值。但无法在where子句

中比较值

这是可用性字段中的JSON

"day": {

    "monday": [
        {
            "start": "1",
            "end": "2",
            "type": "remotely"
        },
        {
            "start": "3",
            "end": "5",
            "type": "inoffice"
        }
    ],

    "sunday": [
        {
            "start": "1",
            "end": "2",
            "type": "remotely"
        },
        {
            "start": "3",
            "end": "5",
            "type": "inoffice"
        }
    ]
}

0 个答案:

没有答案