8.7 连接 Day25

---note---

连接:从两个关系的广义笛卡尔积,再输出满足条件行

自然连接:在结果中去掉重复的属性

distinct  排除相同项

select distinct from

 

  select Sname NAME , 'Year of birth:' Birth , 2008-Sage Birthday , 

IS LOWER(Sdept) Department.

 From student;

!> , !< , <>

 

between and 

not between and 

like , not like 

Is NULL , IS NOT NULL

 

select Sname , Ssex

From Student 

where Sdept IN ('IS','MA','CS');

 

% 代表任意长度的字符串

a%b 表示a开头,b结尾

_ 代表任意单个字符

 

Select *

  from student 

  where Sno like '95001'

  where Sno = '95001'

 

Where Cname like 'DB\_Design'

  ESCAPE '\'

Order by   Group by 只用于最后的结果查询   ASC DESC 

Select count (*)

from student ;

 

select Count (distinct Sno)

  from SC;

 

Select Sno

  from SC

  GROUP by Sno

  having Count(*)>3;

连接查询

  等值连接

 

自身连接

  Select FIRST.Cno , SECOND.Cpno

     from Course FIRST , Course SECOND

外连接:

  from student LEFT OUT JOIN sc ON

    A left out join b on 

---note---

posted on 2016-08-08 14:16  Dengyi  阅读(89)  评论(0编辑  收藏  举报

导航