MongoDB 中的子查询用于检索课程详细信息
我有两个文档:
db.COURSE.insertMany([
{"Course_name" : "Intro to Computer Science",
"Course_number": "CS1310",
"Credit_hours" : 4,
"Department" : "CS"
},
{"Course_name" : "Data Structures",
"Course_number": "CS3320",
"Credit_hours" : 4,
"Department" : "CS"
},
{"Course_name" : "Discrete Mathematics",
"Course_number": "MATH2410",
"Credit_hours" : 3,
"Department" : "MATH"
},
{"Course_name" : "Database",
"Course_number": "CS3380",
"Credit_hours" : 3,
"Department" : "CS"
}
])
db.PREREQUISITE.insertMany([
{
"Course_number":"CS3380",
"Prerequisite_number":["CS3320","MATH2410"]
},
{
"Course_number":"CS3320",
"Prerequisite_number":"CS1310"
}
])
我想查询以检索“数据库”先决条件的 course_name 课程。
我们如何在 Mongo DB 中使用子查询?
I have two documents:
db.COURSE.insertMany([
{"Course_name" : "Intro to Computer Science",
"Course_number": "CS1310",
"Credit_hours" : 4,
"Department" : "CS"
},
{"Course_name" : "Data Structures",
"Course_number": "CS3320",
"Credit_hours" : 4,
"Department" : "CS"
},
{"Course_name" : "Discrete Mathematics",
"Course_number": "MATH2410",
"Credit_hours" : 3,
"Department" : "MATH"
},
{"Course_name" : "Database",
"Course_number": "CS3380",
"Credit_hours" : 3,
"Department" : "CS"
}
])
db.PREREQUISITE.insertMany([
{
"Course_number":"CS3380",
"Prerequisite_number":["CS3320","MATH2410"]
},
{
"Course_number":"CS3320",
"Prerequisite_number":"CS1310"
}
])
I wanted to query to retrieve the course_name of the prerequisites of the “Database”
course.
How can we use subquery in Mongo DB??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论