Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql strong循环:同时使用[和]和[或]条件过滤数据_Mysql_Node.js_Strongloop - Fatal编程技术网

Mysql strong循环:同时使用[和]和[或]条件过滤数据

Mysql strong循环:同时使用[和]和[或]条件过滤数据,mysql,node.js,strongloop,Mysql,Node.js,Strongloop,我尝试使用“and”和“or”条件过滤数据。 我想得到这个mySql查询: SELECT * FROM `data` WHERE ((`property1`=11) OR (`property1`=13)) AND (`property2`=6) 我编写的rest api如下所示: http://localhost:4000/api/Data/?filter[where][or][0][property1]=11&filter[where][or][1][property1]=13&a

我尝试使用“and”和“or”条件过滤数据。 我想得到这个mySql查询:

SELECT * FROM `data` WHERE ((`property1`=11) OR (`property1`=13)) AND (`property2`=6)
我编写的rest api如下所示:

http://localhost:4000/api/Data/?filter[where][or][0][property1]=11&filter[where][or][1][property1]=13&filter[where][and][0][property2]=6
环回json转换似乎是正确的:

{                                            
    "or": [                              
            {                            
                    "property1": 11      
            },                           
            {                            
                    "property1": 13      
            }                            
    ],                                   
    "and": [                             
            {                            
                    "property2": 6     
            }                            
    ]                                    
}
但mySql上的翻译查询是:

SELECT * FROM `data` WHERE (`property1`=11) OR (`property1`=13) AND (`property2`=6)

怎么了?

正确的过滤器如下所示:

{     
    "and": [
        {                            
          "property2": 6     
        } ,
        {
        "or": [                              
            {                            
                    "property1": 11      
            },                           
            {                            
                    "property1": 13      
            }                            
    ]   }    
    ]                              
}

谢谢你,易卜拉欣。json结构很清楚,但我不明白如何从api rest调用中获取此json。@FrancescoDeRosa可能
filter[where][and][0][or][0][property1]=11&filter[where][and][0][or][1][property1]=13&filter[where][and][1][property2]=6
您需要将
封装到
中。