-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex19dbms
89 lines (70 loc) · 1.62 KB
/
ex19dbms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
19
NoSQL– RETRIEVING DATA
__________________________Q1_____________________________________________________
Write a MongoDB query to display the customer documents having city ‘ekm’,’tvm’.
> db.customer.find({$or:[{address:"ekm"},{address: "tvm"}]}).pretty()
{
"_id" : ObjectId("62a821a118ce006153882222"),
"id" : 2,
"name" : "aneeta",
"address" : "ekm",
"pn_no" : 9898,
"age" : 25
}
{
"_id" : ObjectId("62a821b218ce006153882223"),
"id" : 1,
"name" : "kavya",
"address" : "tvm",
"pn_no" : 8898,
"age" : 25
}
___________________________________Q2___________________________________________
Write a MongoDB query to display all customer documents who have age >20.
> db.customer.find({age:{$gt:20}}).pretty();
{
"_id" : ObjectId("62a821a118ce006153882222"),
"id" : 2,
"name" : "aneeta",
"address" : "ekm",
"pn_no" : 9898,
"age" : 25
}
{
"_id" : ObjectId("62a821b218ce006153882223"),
"id" : 1,
"name" : "kavya",
"address" : "tvm",
"pn_no" : 8898,
"age" : 25
}
>
____________________________3________________________________________________
Write a MongoDB query to find customer documents who not live in ‘tvm’.
> db.customer.find({"address":{$ne:"tvm"}}).pretty()
{
"_id" : ObjectId("62a821a118ce006153882222"),
"id" : 2,
"name" : "aneeta",
"address" : "ekm",
"pn_no" : 9898,
"age" : 25
}
{
"_id" : ObjectId("62a821ea18ce006153882226"),
"id" : 5,
"name" : "reem",
"address" : "calicut",
"pn_no" : 7798,
"age" : 10
}
{
"_id" : ObjectId("62a821f618ce006153882227"),
"id" : 6,
"name" : "reet",
"address" : "malappuram",
"pn_no" : 7798,
"age" : 10
}
>
//VERIFIED