What would be the Mongodb equivalent of the 2 following SQL queries?
SELECT A.Lname FROM Assistant A INNER JOIN Manager Ma ON A.RefNum = Ma.RefNum
GROUP BY A.Lname HAVING COUNT(DISTINCT Ma.Manager) > 1;
SELECT G.Cname, R.Snum FROM Game G
INNER JOIN Role R ON G.Cnum = R.Cnum
WHERE G.level>200;
Dear Student,
Here are the MongoDB equivalents of the 2 SQL statements,
db..group({
"key":{
"A.Lname ": true
},
"initial": {
},
"reduce": function( obj , prev ){
},
"finalize": function( prev ){
},
"cond": {
"$where": "this.CT A.Lname FROM Assistant A INNER JOIN Manager Ma ON A.RefNum == this. Ma.RefNum "
}
});
db.GameG INNER JOIN Role R ON G.Cnum = R.Cnum .find({
"G.level":{ "$gt" : 200 }
},{
"G.Cname": 1,
"R.Snum": 1
}
);
Get Answers For Free
Most questions answered within 1 hours.