与测试共存,与朋友共勉!

SQL语句实例 5

上一篇 / 下一篇  2010-05-15 15:30:41 / 个人分类:转载

 
6.5外连接查询
select student.snosnamessexsagesdeptcnograde

from studentsc

where student.sno = sc.sno(*)

6.6复合条件连接查询

select student.sno, student.sname

from student, sc

where student.sno = sc.sno and sc.cno= ' 2 ' and sc.grade > 90

七.嵌套查询

7.1带有in谓词的子查询

select snosname最后在student关系中

from student取出snosname

where sno in

(select sno然后在sc关系中找出选

from sc修了3号课程的学生学号

where cno in

(select cno首先在course关系中找出

from course息系统的课程号,结果为3

where cname= ‘信息系统));

7.2带有比较运算符的子查询

select snosnamesdept

from student

where sdept =

select sdept

from student

where sname= '刘晨'

7.3带有any(某个)或all(任何一个)谓词的子查询

all谓词select snamesage

from student

where sage < all

(select sage

from student

where sdept= ' is ') and sdept <> ' is ’;

用集函数select snamesage

from student

where sage <

(select min(sage)

from student

where sdept= ' is ') and sdept <>' is

7.4带有exists谓词的子查询

select sname

from student

where not exists

(select *

from sc

where sno = student.sno and cno='1')


TAG:

 

评分:0

我来说两句

我的栏目

日历

« 2024-04-28  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 14505
  • 日志数: 26
  • 图片数: 1
  • 建立时间: 2007-06-10
  • 更新时间: 2010-05-17

RSS订阅

Open Toolbar