MongoDB Command---Pattern query statement

Source: Internet
Author: User
Tags mongodb

Gossip less

Find the product information----The price is less than 200 contains the product name, the goods number, the price, adds the information and so on

Db.goods.find ({"Shop_price": {$lt: $}},{"Shop_price":1,"Goods_name":1,"goods_id":1,"Add_time":1})

Items not classified as 3

Db.goods.find ({"cat_id": {$ne:3}},{"Shop_price":1,"Goods_name":1,"goods_id":1,"cat_id":1})

Items with a price below or equal to 400

Db.goods.find ({"Shop_price": {$lte: -}},{"Goods_name":1,"goods_id":1,"Shop_price":1,"cat_id":1})

To investigate goods with a price greater than or equal to 100, less than or equal to 500

Db.goods.find ({$and: [{"Shop_price": {$lte: -}},{"Shop_price": {$gte: -}}]   },{"Goods_name":1,"goods_id":1,"Shop_price":1,"cat_id":1})

Query does not belong to column 3 and column 11 products with $and

 db.goods.find ({$and: [{cat_id:{$ne:  3 }},{cat_id:{$ne:   }}]},{  "  Goods_name   ": 1 , "  goods_id   ": 1 ,  " shop_price  Span style= "COLOR: #800000" > ": 1 , "  cat_id   ": 1  })  

Query does not belong to column 3 and column 11 products with $nin

Db.goods.find ({"cat_id": {$nin: [3, One]}},{"Goods_name":1,"goods_id":1,"Shop_price":1,"cat_id":1})

Query does not belong to column 3 and column 11 products with $nor

 db.goods.find ({$nor: [{cat_id:  3 },{cat_id:11  Span style= "COLOR: #000000" >}]},{  " goods_ Name   ": 1 ,  " goods_id   ": 1 , "  shop_price   ": 1 , "  cat_id   ": 1  } 
)

Remove items greater than 100 or less than 300 or less than 5000, greater than 4000

db.goods.find {$or: [{$and: [ {"Shop_price": {$lte: -}},{"Shop_price": {$gte: -}},]},{$and: [{"Shop_price": {$lt: the}},{"Shop_price": {$gt:4000}},]}]},{"Goods_name":1,"goods_id":1,"Shop_price":1,"cat_id":1}) 

Take out the item number 5 to find the remainder equals 1 of the record

Db.goods.find ({cat_id:{$mod: [5,1]}},{"goods_name" :1,"goods_id":1,"shop_price  ":1,"cat_id":1})

Remove items classified as 3 or 11

Db.goods.find (
{"cat_id": {$in: [3,11]}},
{"goods_name": 1, "goods_id": 1, "Shop_price": 1, "cat_id": 1}
)

MongoDB Command---Pattern query statement

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.