惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Spread Privacy
Spread Privacy
Engineering at Meta
Engineering at Meta
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
DataBreaches.Net
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
L
LangChain Blog
Jina AI
Jina AI
MongoDB | Blog
MongoDB | Blog
B
Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
T
Threatpost
V
V2EX
Security Archives - TechRepublic
Security Archives - TechRepublic
GbyAI
GbyAI
Scott Helme
Scott Helme
Cyberwarzone
Cyberwarzone
H
Help Net Security
大猫的无限游戏
大猫的无限游戏
Security Latest
Security Latest
T
The Exploit Database - CXSecurity.com
T
Tenable Blog
S
Schneier on Security
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
F
Full Disclosure
腾讯CDC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Security @ Cisco Blogs
A
Arctic Wolf
S
Securelist
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
Tor Project blog
The Register - Security
The Register - Security
L
LINUX DO - 最新话题
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
L
LINUX DO - 热门话题
TaoSecurity Blog
TaoSecurity Blog
Y
Y Combinator Blog
博客园 - 三生石上(FineUI控件)
C
CERT Recently Published Vulnerability Notes

博客园 - 魔幻紫光

HTML5学习笔记4 HTML5学习笔记3 HTML5学习笔记2 HTML5学习笔记1 How To Allow Blocked Content on Internet Explorer 「2014年間休日カレンダー」のご案内 Excel VBA编程的常用代码 Eclipse的几点使用技巧 2007年下半年系统分析师上午试卷及参考答案 我的漫漫系分路 ActiveX简单介绍 Java程序设计问答大全(二) Java程序设计问答大全(一) 整天工作的人为何当不了富翁 美丽的新娘,祝你幸福! 快速放松的11种简单方法 职场回顾:面试精华试题大全[转] 李彦宏:十天不用百度你试试 删除怪文件
SQL UNION
魔幻紫光 · 2007-03-12 · via 博客园 - 魔幻紫光

UNION 指令的目的是将两个 SQL 语句的结果合并起来。从这个角度来看, UNION 跟 JOIN 有些许类似,因为这两个指令都可以由多个表格中撷取资料。 UNION 的一个限制是两个 SQL 语句所产生的栏位需要是同样的资料种类。另外,当我们用 UNION这个指令时,我们只会看到不同的资料值 (类似 SELECT DISTINCT)。 
UNION 的语法如下:

[SQL 语句 1]
UNION
[SQL 语句 2]

假设我们有以下的两个表格,

Store_Information 表格
store_name  Sales  Date 
Los Angeles  $1500  Jan-05-1999 
San Diego  $250  Jan-07-1999 
Los Angeles  $300  Jan-08-1999 
Boston  $700  Jan-08-1999 

 
Internet Sales 表格  Date  Sales 
Jan-07-1999  $250 
Jan-10-1999  $535 
Jan-11-1999  $320 
Jan-12-1999  $750 
 


而我们要找出来所有有营业额 (sales) 的日子。要达到这个目的,我们用以下的 SQL 语句:

SELECT Date FROM Store_Information
UNION
SELECT Date FROM Internet_Sales

结果:

Date
Jan-05-1999
Jan-07-1999
Jan-08-1999
Jan-10-1999
Jan-11-1999
Jan-12-1999


有一点值得注意的是,如果我们在任何一个 SQL 语句 (或是两句都一起) 用 "SELECT DISTINCT Date" 的话,那我们会得到完全一样的结果。