Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Query expression exercise

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report