我来自Oracle PLSQL背景,我才刚刚开始学习MongoDB命令。
for i in df.loc[np.isnan(df['s_number'])].index:
df['s_number'] = -sum(df[:i])
df['cumsum'] = df['s_number'].cumsum()
index s_number s_cumsum
0 0 1.0 1
1 1 4.0 5
2 2 6.0 11
3 3 -11.0 0
4 4 7.0 7
5 5 2.0 9
6 6 3.0 12
7 0 1.0 13
8 1 4.0 17
9 2 6.0 23
10 3 -23.0 0
11 4 7.0 7
12 5 2.0 9
13 6 3.0 12
我需要查询以下文件:
>db.Employee.find()
{ "_id" : 10, "EmployeeName" : "Smith" }
{ "_id" : 20, "EmployeeName" : "Nandhi" }
{ "_id" : 30, "EmployeeName" : "Rajan" }
{ "_id" : 50, "EmployeeName" : "Raju" }
我写了如下对应的代码:
WHERE EmployeeName = "Smith" OR (EmployeeName = "Rajan" AND _id = 30);
错误消息
2019-03-13T22:48:26.123 + 0530 E查询[js]语法错误:无效 属性ID @(shell):1:47
答案 0 :(得分:1)
您的$or
术语必须位于单独的对象中:
db.Employee.find({$or:[{"EmployeeName":"Smith"}, {"EmployeeName":"Rajan", "_id":30}]})
答案 1 :(得分:0)
括号被错误地括起来。像这样使用
db.Employee.find({$or:[{"EmployeeName":"Smith"},{"EmployeeName":"Rajan","_id":30}]})