您的位置:首页 > 博客中心 > 数据库 >

SQL中的Filter, join, semi-join等概念的释义

时间:2022-03-13 22:51

经常在工作中用到,虽然当年在数据库原理课程中学习过,不过基本已经还给老师了。工作这么多年,感觉自己在学习上倒退了很多,惭愧。这篇帖子,作为SQL相关知识的整理贴。

 

1、semi-join(半连接)(来自:)

半连接返回表中能够与另一表中连接的记录(并不执行一次全连接),它并没有一个明确的语法格式。

A semi-join returns rows from one table that would join with another table without performing a complete join. It doesn‘t have explicit syntax. 

例子,从表Customers中选择其ID出现在表Sales中的客户的ID和Name:
select * 
from Customers C 
where exists ( 
select * 
from Sales S 
where S.Cust_Id = C.Cust_Id 


Cust_Id Cust_Name 
----------- ---------- 
2 John Doe 
3 Jane Doe

来看看这篇文章:,比较详细的介绍了Oracle中的半连接。惭愧啊,话说这个帖子里面的这个语句我就没看懂:

create table table_1
as select
cast(rownum as int) a,
cast(rownum+10 as int) b,
cast(dbms_random.string(‘i‘,10) as varchar2(10)) c
from dual connect by level<=500000

看了这篇文章和这篇才明白。

 

2、join(连接)(来自:)

总共有四种连接类型:

内连接:

全连接:

左连接:

右连接:

 

3、aggregation(聚合)(来自:)

聚合函数对一组值执行计算,并返回单个值。 除了 COUNT 以外,聚合函数都会忽略空值。 聚合函数经常与 SELECT 语句的 GROUP BY 子句一起使用。

SQL中的Filter, join, semi-join等概念的释义,布布扣,bubuko.com

热门排行

今日推荐

热门手游