sql语句怎么实现在两个表中查询
我想在表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)