我要检索两张表,一个学生信息表StudentInfo,一张学生课堂成绩统计表,现在我要查找所有学生信息及成绩情况,所以我想到有左连接select * from studentinfo left join lessonscore on studentinfo.studentid=lessonscore.studentid and lessonid=1OK,到这没有问题,但是我现在只想检索特定年级的学生信息,然后再连接对应的成绩表信息,比如5年级所以我这样写:select * from studentinfo where grade=5 left join lessonscore on studentinfo.studentid=lessonscore.studentid and lessonid=1就提示 在关键字 'left' 附近有语法错误。哪位高手指教一下,应该怎么写,才能实现我的要求呢

解决方案 »

  1.   

    select * from studentinfo left join lessonscore on studentinfo.studentid=lessonscore.studentid where lessonid=1 and grade=5
    where 应写在后面!!
      

  2.   

    写在最后一个where后面或者在on后面写:
      

  3.   

    select * from studentinfo  left join lessonscore on studentinfo.studentid=lessonscore.studentid and lessonid=1 where grade=5
      

  4.   

    select * from studentinfo  left join lessonscore on studentinfo.studentid=lessonscore.studentid and lessonid=1 where
    studentinfo.studentid in(select * from studentinfo  where grade=5)
      

  5.   

    CSDN的结贴有问题,明明分都给大家了,但是结果全是0分,版主怎么回事啊????