Sql server中左连接语句

数据库中学生表和课程表如下:

  

左连接sql语句:

select a.studentName,a.studentAge,b.courseName 
from student a left join course b //left join 左连接,以左表为主
on a.studentID=b.studentID

查询结果如下:

查询的结果是以左表student为主,student对应的studentID在右表course如果不存在的话,就会用NULL值来代替。

posted @ 2015-04-03 11:46  一夜秋2014  Views(2679)  Comments(0Edit  收藏  举报