Query expression exercise
Three query knowledge
Note: the following query is based on the list of goods on the ecshop website (ecs_goods).
In practice, you can take only part of the columns for easy viewing.
1: exercise for basic query where:
Identify goods that meet the following conditions
1.1: goods with a primary key of 32
Db.goods.find ({goods_id:32})
1. 2: all goods not in column 3 ($ne)
Db.goods.find ({cat_id: {$ne:3}}, {goods_id:1,cat_id:1,goods_name:1})
1.3goods priced above 3000 yuan in our store {$gt}
Db.goods.find ({shop_price: {$gt:3000}}, {goods_name:1,shop_price:1})
Goods whose price is less than or equal to 100RMB in our store ($lte)
Db.goods.find ({shop_price: {$lte:100}}, {goods_name:1,shop_price:1})
1.5: take out the goods in column 4 or 11 ($in)
Db.goods.find ({cat_id: {$in: [4Jing 11]}}, {goods_name:1,shop_price:1})
1.6: take out 100