我想在表tb_lesson中查询出来sectionID=1的所有数据的lessonID,然后通过lessonID在表tb_lessonGrade中查到到对应的grade。这个怎么用sql语句实现啊各位大神。
------解决方案--------------------
select grade from tb_lessonGrade where lessonID in(
select lessonID from tb_lesson where sectionID=1
)
------解决方案--------------------
select * from
(
select * from tb_lesson tbl where tbl.sectionID=1
) a
inner join tb_lessonGrade tblg
on a.lessonID = tblg.lessonID
------解决方案--------------------
SELECT DISTINCT grade
FROM tb_lessonGrade
WHERE lessonID IN(
SELECT DISTINCT lessonID
FROM tb_lesson
WHERE sectionID=1
)
------解决方案--------------------
select grade from tb_lessonGrade where lessonID in (select DISTINCT le.lessonID from tb_lesson le where sectionID=1)