`
编程足球
  • 浏览: 251514 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

SQL 连接查询

    博客分类:
  • SQL
 
阅读更多
连接查询是指一个查询同时涉及到两个及以上的表。包括:
等值连接,自然连接,非等值连接,自身连接,外连接,复合查询.等...
1. 等值连接 于非等值连接
//   查询每个学生及选课的情况
select Student.*,SC.*
from Student,Sc
where Student.Sno = SC.Sno;


2.自然连接
在等值连接中把目标列的重复属性去掉则为: 自然连接
//   查询每个学生及选课的情况
Select Student.Sno,Student.name,Ssex,Sage,Sdept,Cno,Grade
from Student,Sc
where Student.Sno = SC.Sno;


3.自身连接
//  查询每门课的间接选修课(即选修课的选修课)
select First.Cno,Second.Cpno
From Course First,Course Second
Where First.Cpno = Second.Cno;



4.外连接
   
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics