AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Mongodb compass select distinct1/7/2024 ![]() We will use the $and operator explicitly when we use it more complex queries mixing different conditions – as we will see in the next examples to come. There is an $and operator, but in this simple scenario we can leave it implicit. In MongoDB we filter by mutiple fields by separating the different fields we want to use as a filter by comas. SELECT * FROM customers WHERE VIP IS true AND Country = "Germany" To retrieve all the customers in our collection that are from Germany, and are VIP we will run this command: How do I filter a MongoDB collection by multiple fields? Now, without further ado let’s dive into how we can extract data from our MongoDB customers collections. Each customer object has the following self-explanatory fields: In our examples we will use a collection that contains a list of customers. If you want to try your hand at MongoDB, but you don’t want to go through the hassle of installing MongoDB in your computer you can use an online MongoDB playground like this one here, or this one. If you are new to MongoDB, you may want to read first this post about how to install MongoDB and its basic commands. ![]() ![]() When working with MongoDB there are some operations we perform over and over again to retrieve information from the database: let’s see the ways to query the MongoDB collections filtering by different conditions.įor those coming from a traditional SQL background, I will provide also the SQL equivalent of the MongoDB statements. ![]()
0 Comments
Read More
Leave a Reply. |