在MySQL多年后,我是MongoDB的新手,并试图用php Composer
在MongoDB中弄清楚此等效查询从表中选择 *(x> 0和x< 30(或x ='falf'和sid = 1
$query = [
'$and' => [
[
'sid'=> 1
], ['$and' => [[
'info.x' => [
'$lt' => '30'
]
], [
'info.x' => [
'$gt' => '0'
]
], [
'info.x' => [ /// i want to put this in $or
'half'
]
]]
]
]
];
我想显示所有大于0且比30或等于"一半"的大小
谢谢
必须是
db.collection.find({
"$or": [
{ "x": { "$gte": 0, "$lte": 30 }},
{ "x": "half" }
],
"sid": 1
})
或
$query = [
'$or'=> [
[ 'x'=> [ '$gte'=> 0, '$lte'=> 30 ]],
[ 'x'=> 'half' ]
],
'sid'=> 1
]