i need the value only it
size.h
SQL like :
SELECT size.h from inventory WHERE status = “A”
and the MongoDB shell how can i do it ?
i need the value only it
size.h
SQL like :
SELECT size.h from inventory WHERE status = “A”
and the MongoDB shell how can i do it ?
Hello, @AtlantisDe!
You can use this query:
db.inventory.find(
{ status: 'A' }, // where
{ _id: true, 'size.h': true } // select
);
It will produce the following output:
[
{ "_id" : ObjectId("5f355cdb920ca5b143d09356"), "size" : { "h" : 14 } },
{ "_id" : ObjectId("5f355cdb920ca5b143d09357"), "size" : { "h" : 8.5 } },
{ "_id" : ObjectId("5f355cdb920ca5b143d0935a"), "size" : { "h" : 10 } }
]
Checkout some pages in the official MongoDB documentation:
I strongly recommend you to take some free Basic MongoDB course to be able to resolve such tasks easily
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.