联表多条件查询SQL编写

发布于 5 年前作者 leijing5265 次浏览最后编辑 5 年前来自 share
db.collection('student')
.aggregate()
.match({
sex: 1
})
.lookup({
from: 'teacher',
let:{
teacherId: '$teacherId'
},
pipeline: $.pipeline()
.match(_.expr($.and([
$.eq(['$teacherId', '$$teacherId']),
$.eq(['$studentName', '捌玖'])
]))).done(),
as: 'dataList'
})
.end()

student 表与 teacher 表关联查询,条件:student.studentName=‘捌玖’ and teacher.sex=1

0 回复
暂无回复