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值来代替。

浙公网安备 33010602011771号