- 浏览: 121642 次
- 性别:
- 来自: 火星
文章分类
最新评论
-
hj01kkk:
不错:grin:
extjs treepanel动态改变树节点的图标 -
xiangzhu100:
请问你有folder.gif的图片么?发给我??
extjs treepanel动态改变树节点的图标 -
viken:
确实, 相当郁闷
struts2 ognl.MethodFailedException -
gpl414713065:
谢谢啦
div被flash遮住的问题 -
mcqueen:
spring1118 写道此代码直接添加到Treepanel中 ...
extjs treepanel动态改变树节点的图标
SQL queries are combined using the UNION operator. Using UNION, multiple SELECT statements can be specified, and their results can be combined into a single result set.
SELECT cust_name, cust_contact, cust_email FROM Customers WHERE cust_state IN ('IL','IN','MI') UNION SELECT cust_name, cust_contact, cust_email FROM Customers WHERE cust_name = 'Fun4All' ORDER BY cust_name, cust_contact;
【Using UNION, the DBMS automatically removes any duplicate rows from the query result set .】
UNION instructs the DBMS to execute both SELECT statements and combine the output into a single query result set.
UNION Rules
As you can see, unions are very easy to use. But there are a few rules governing exactly which can be combined:
-
A UNION must be comprised of two or more SELECT statements, each separated by the keyword UNION (so, if combining four SELECT statements there would be three UNION keywords used).
-
Each query in a UNION must contain the same columns, expressions, or aggregate functions (although columns need not be listed in the same order).
-
Column datatypes must be compatible: They need not be the exact same type, but they must be of a type that the DBMS can implicitly convert (for example, different numeric types or different date types).
Including or Eliminating Duplicate Rows
Go back to the preceding section titled "Using UNION" and look at the sample SELECT statements used. You'll notice that when executed individually, the first SELECT statement returns three rows, and the second SELECT statement returns two rows. However, when the two SELECT statements are combined with a UNION, only four rows are returned, not five.
The UNION automatically removes any duplicate rows from the query result set (in other words, it behaves just as do multiple WHERE clause conditions in a single SELECT would). Because there is a Fun4All location in Indiana, that row was returned by both SELECT statements. When the UNION was used the duplicate row was eliminated.
This is the default behavior of UNION, but you can change this if you so desire. If you would, in fact, want all occurrences of all matches returned, you can use UNION ALL instead of UNION.
Look at the following example:
SELECT cust_name, cust_contact, cust_email FROM Customers WHERE cust_state IN ('IL','IN','MI') UNION ALL SELECT cust_name, cust_contact, cust_email FROM Customers WHERE cust_name = 'Fun4All';
【Using UNION ALL, the DBMS does not eliminate duplicates.】
Sorting Combined Query Results
This UNION takes a single ORDER BY clause after the final SELECT statement,multiple ORDER BY clauses are not allowed. Even though the ORDER BY appears to only be a part of that last SELECT statement, the DBMS will in fact use it to sort all the results returned by all the SELECT statements.
SELECT cust_name, cust_contact, cust_email FROM Customers WHERE cust_state IN ('IL','IN','MI') UNION SELECT cust_name, cust_contact, cust_email FROM Customers WHERE cust_name = 'Fun4All' ORDER BY cust_name, cust_contact;
发表评论
-
oracle常用命令及常见错误
2012-02-29 13:20 829--导出数据库 exp test2/test2@trp ... -
多sqlserver实例共存jdbc连接
2011-12-15 14:24 758default: jdbc:jtds:sqlserver ... -
oracle em不能启用
2011-11-18 12:28 3C:\Documents and Settings\Admin ... -
oracle常用函数
2011-11-14 10:30 672NVL(Expr1,Expr2)如果Expr1为NULL, ... -
Oracle备份恢复
2011-07-29 14:16 442一、按照备份进行的方式,可以分为逻辑备份EXP/IMP、冷备份 ... -
[转载]ORACLE详解:数据库名、实例名、ORACLE_SID、数据库域名、全局数据库名、服务名
2011-07-05 16:15 930详解:数据库名、实 ... -
ORACLE的所有字段类型
2011-06-15 10:53 993字段类型 中文说明 限制条件 其它说明 ... -
ORACLE的所有字段类型
2011-06-15 10:51 1字段类型 中文说明 限制条件 其它说明 ... -
win7下PowerDesigner 12.5使用过程中总是提示打印错误的解决办法
2011-06-14 22:41 1065我的电脑 -> 管理-> 服务和应用程序 - ... -
数据库调优性能调优[转载]
2011-06-09 17:12 935数据库调优可以使数 ... -
查看oracle版本信息
2011-06-03 10:45 759select * from product_com ... -
[Teach Youself SQL in 10 Minutes] insert into..select...
2011-05-28 14:16 689意为把tableA的aa/bb/cc的数据插入到tableB的 ... -
[Teach Youself SQL in 10 Minutes] SQL JOIN TABLE
2011-05-13 09:07 644语法: SELECT column_name(s) ... -
ORACLE的i与g
2011-04-29 15:19 10261998年9月,ORACLE公司正式发布ORACLE 8i。& ... -
[Teach Youself SQL in 10 Minutes] inserting data
2011-04-14 11:08 8191. Inserting Retrieved Data I ... -
[Teach Youself SQL in 10 Minutes] joining tables
2011-04-14 09:34 883一、inner joins A join based on ... -
[Teach Youself SQL in 10 Minutes] SELECT Clause Ordering
2011-04-13 16:45 864Clause Description ... -
[Teach Youself SQL in 10 Minutes] Grouping and Sorting
2011-04-13 16:33 844ORDER BY GROUP BY ... -
[Teach Youself SQL in 10 Minutes] The difference between HAVING and WHERE
2011-04-13 16:15 784The difference between HAV ... -
identifying relationship or non-identifying relationship
2009-10-16 14:16 5740判别一个关系是Non-Identifying还是Iden ...
相关推荐
Sams Teach Youself SAP in 24 Hours(sap基础教程英文原版)
10. **UML工具**:学习UML时,你可能会使用各种建模工具,如IBM Rational Rose、Enterprise Architect、Visual Paradigm等,这些工具可以帮助你绘制和管理UML模型。 通过这24小时的学习旅程,你将深入理解UML的各个...
### UML 24小时入门知识点详解 #### 一、UML概述 - **定义**:UML(Unified Modeling Language,统一建模语言)是一种标准化的可视化建模语言,广泛应用于软件工程领域,用于描述系统架构、设计模式及业务流程等。...
《教你21天学会Perl 5》是一本旨在帮助初学者快速掌握Perl编程语言的经典教程。Perl 5是Perl编程语言的一个主要版本,以其强大的文本处理能力、灵活的语法和广泛的用途而闻名。这本书通过21天的学习计划,将Perl 5的...
《21天学通C++ Teacher Yourself in 21 Days》是一本专为初学者设计的C++编程教程,旨在帮助读者在短短三周内掌握C++基础。这本书以实践为导向,通过逐步引导的方式,让学习者每天都能接触到新的概念和技术,从而在...
国外经典Java教材,Sams Teach Youself Java in 21 Days第六版的源代码,本书涉及Java7和Android的知识,帮助读者编写高效的Java程序和Android应用! 作者:Rogers 译者:冯志祥等 出版社:人民邮电出版社
10. **实战项目**:通过实际的小型项目,比如计时器、图片轮播、表单验证等,帮助读者巩固所学知识并提高实践能力。 这本书作为开源资源,意味着读者可以免费获取并学习,同时也可以查看和贡献源码,这对于初学者来...
这是SAMS Teach youself boorland C++Builder in 21 days一书的源代码,中文名Borland C++Builder3.0自学培训教程(希望公司出版).但此中文版并未配源码,使自学大打折扣.现在我把这套源码放在这,希望有这本书的读者能...
Here are FFTW lib and dll files compiled by GCC4.5 and VC2010 in Win7. But I suggest you compiling it by youself in you computer, or there will be some unpredictable errors!
10. Now you are ready to use the control in your Web form. Just drag the LoginControl icon in the ToolBox pane and drop it to the Web form. The control should appear in the form with all its child ...
"JAVA_learn_by_youself.rar" 这个压缩包文件就是专为那些想要踏上Java编程旅程的人准备的一份宝典。它包含了"JAVA 自学之路指南.doc",这份文档将是你学习Java的重要参考资料。 首先,让我们深入理解Java编程的...
SEO For 2016 – The Complete Do It Yourself SEO Guide
4.row definition by youself (Render) 5.succinct code (size of origin code is under 10k, after compress it is under 3k), update easily. 6.easy study and use 7.easy custom css style Just a little ...
app lock for you to lock youself apps which you can not see for others
This is a library of the AnimatorSet,it has three move path and many animation,you can make a easy animation of view by youself. animation of View i did not finish it at this time Demo MovePath ...
Extract to any folder, and you can use it, make youself happy:) THIS IS A THIRD-PARTY SOFTWARE. IT IS PROVIDED "AS IS", WITHOUT ANY WARRANTY. If it does not meet your needs, please install the full ...
简明批处理教程22009年10月20日 星期二 下午 05:35 最近对于批处理技术的探讨比较热,也有不少好的批处理程序发布,但是如果没有一定的相关知识恐怕不容易看懂和理解这些批处理文件,也就更谈不上自己动手编写了,古...
char a[]=" lo v ely a dm inistration d youself my"; int p,q; int i; p=0,q=0; strPositon(a,&p,&q); printf("the most long word is :"); for(i=p;i;i++) printf("%c",a[i]); return 0; } void ...