【发布时间】:2020-08-05 04:40:15
【问题描述】:
我是 SQL 查询新手,第一次使用 Pymongo 使用 MongoDB。
我在 MongoDB 中有两个集合。
DEPARTMENT
dept_id dept_name status location
------------------------------------------
123 sales active New York
248 IT inactive Vermont
845 HR active LA
EMPLOYEE
dept_id emp_name emp_salary emp_status emp_id
----------------------------------------------------
123 John 25000 active xyz
845 Mary 90000 active abc
248 Kevin 50000 inactive qrs
query 1
select * from DEPARTMENT where dept_id=123 and status='active'
query 2
select emp_name, emp_id from EMPLOYEE where dept_id =123 and status = 'active'
我想内部加入这 2 个查询并返回所有匹配的记录,并提供 DEPARTMENT 表和 emp_name、emp_id 表中的所有详细信息。
我将如何使用 pymongo 和 sql 查询来实现它。
任何帮助将不胜感激!
提前致谢!
【问题讨论】:
标签: python sql mongodb pymongo