将SQL查询转换为包含联接和嵌套表的mongoDB

时间:2016-12-13 18:07:30

标签: mysql sql mongodb

我对mongoDB完全不熟悉,并想知道是否甚至可以用mongo语言查询这样的内容:

SELECT 
stg.emp_user_id as emp_user_id,
stg.mgr_user_id as mgr_user_id,
stg.emp_email as emp_email,
stg.employeetype as employeetype,
s.shift_start_time as  shift_start_time,
s.shift_end_time as  shift_end_time,
s.days_worked as days_worked,
s.num_employees as num_employees,
FROM(
#nested table to link the employee to the manager, based on employee email
SELECT
u.userid as emp_user_id,
p.userid as mgr_user_id,
u.email as emp_email,
u.employeetype as employeetype,
FROM Users u
LEFT JOIN Peoples p on u.email = p.email) stg
#bring in shifts table linked to mgr, now that we have mgr-emp relationship
LEFT JOIN shifts s ON stg.mgr_user_id = s.user_id;

我一直在环顾四周,能够找到简单的转换引用(querymongo.com,stackoverflow示例等),但没有找到任何连接和嵌套表。任何帮助/方向将不胜感激!

0 个答案:

没有答案