sql语句的联合查询(join 用法)

student
no,name,classid,
1, zdy,2,
2,huz,2,
3,yxx,2,
4,sss,1,

class
classid,classname,
2,y2002,
3,y2003,

1 .select *  from student , class where student.classid=class.classid
no,name,classid,classid,classname,
1,zdy,2,2,y2002,
2,huz,2,2,y2002,
3,yxx,2,2,y2002,

2.select *  from student left join class on student.classid=class.classid
no,name,classid,classid,classname,
1,zdy,2,2,y2002,
2,huz,2,2,y2002,
3,yxx,2,2,y2002,
4,sss,1, ,  ,

3.select *  from student inner join class on student.classid=class.classid
no,name,classid,classid,classname,
1,zdy,2,2,y2002,
2,huz,2,2,y2002,
3,yxx,2,2,y2002,
结果同1

4.select *  from student right join class on student.classid=class.classid
no,name,classid,classid,classname,
1,zdy,2,2,y2002,
2,huz,2,2,y2002,
3,yxx,2,2,y2002,
  ,    ,  , 3,y2003,

你可能感兴趣的:(Other)