您的位置:首页 > 数据库

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

2004-11-10 12:29 811 查看
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,
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  join sql class