sixth day

 1  Noncorrelated Subqueries

A noncorrelated subquery is a subquery that is independent of the outer query. In other words, the subquery

could be executed on its own. The following is an example of a query that is not correlated:

--从表中得到等级为A的学生的名字
SELECT  s.sname
FROM    Student s
WHERE   s.stno IN
(SELECT gr.student_number
 
FROM    Grade_report gr
             
WHERE   gr.grade = 'A')

The first part of the preceding query (the first three lines) is the main,

 

outer query, and the second part (the part in parentheses) is the subquery

 

(also referred to as an inner, nested, or embedded query). To demonstrate

 

that this subquery is an independent entity, you could run it by itself:

 
SELECT   gr.student_number
 
FROM    Grade_report gr
 
WHERE   gr.grade = 'A'
 
两个表是相互独立的两部分 能够独立的进行运行
 
 
2   Correlated Subqueries
 
 a correlated subquery is an inner subquery whose information is referenced 
 
 by the main, outer query such that the inner query may be thought of as being 
 
 executed repeatedly.
 
 The correlated subquery cannot stand alone, as it depends on the outer query; 
 
therefore, completing the subquery prior to execution of the outer query is not
 
an option. The efficiency of the correlated subquery varies; it may be worthwhile 
 
to test the efficiency of correlated subqueries versus joins or sets.
 
 
The correlated subquery acts like a nested DO loop in a programming language, 
 
where the first row from the Student table is SELECTed and tested against all
 
 the rows in the Grade_report table, and then the second Student row is SELECTed 
 
and tested against all rows in the Grade_report table. The following is the DO loop
 
 in pseudocode:
 
LOOP1: For each row in Student  s  DO
      
LOOP2: For each row in Grade_report  gr  DO
             
IF (gr.student_number = s.stno) THEN
                   
IF (gr.grade = 'B') THEN TRUE
      
END LOOP2;
     
IF TRUE, THEN Student row is SELECTed
END LOOP1
for example
--一个Correlated Subqueries例子
SELECT  s.sname
FROM    Student s
WHERE   s.stno IN
 
(
SELECT      gr.student_number
  
FROM        Grade_report gr, Section
  
WHERE       Section.section_id = gr.section_id
  
AND           Section.course_num LIKE 'COSC%'
 
AND           gr.student_number = s.stno
 
AND           gr.grade = 'B')
 
 
3 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
《无机化学(第六版)》是一本流行的教科书,用于学习无机化学的学生和专业人士。它被广泛认可为无机化学领域的权威参考书籍,并已经发行了多个版本。无机化学是研究无机物和无机反应的化学分支,涵盖了无机化合物的结构、性质、合成方法以及与生物和环境的相互作用。 本书的第六版更新了以往版本的内容,并新增了最新的研究和发现。它以简明清晰的语言阐述了无机化学的基本原理和理论,同时提供了大量的实例和案例研究,帮助读者更好地理解和应用所学知识。 《无机化学(第六版)》的章节安排清晰,包括无机化合物的基本性质、配位化学、羰基和膦配合物、固体结构和化学、主族元素、过渡金属和锕系元素等。每个章节都有详细的解释和示例,有助于读者巩固所学的概念和原理。 此外,本书还提供了习题和答案,供读者进行自我测试和巩固知识。部分习题还附有解题思路和方法,帮助读者更好地理解和应用所学知识。 《无机化学(第六版)》是一本权威且全面的教材,适用于大学本科无机化学课程的学生以及从事无机化学研究的专业人士。它是学习无机化学的重要参考资料,可以帮助读者深入理解和应用无机化学的原理和方法。无机化学的研究是理解和应用化学知识的重要组成部分,而这本教材将成为您学习该领域的不可或缺的工具。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值