CSDN博客

img evilzydar

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

发表于2004/11/10 12:29:00  2912人阅读

分类: Other

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,

阅读全文
0 0

相关文章推荐

img
取 消
img