![]() |
Union, Union all, Intersect and Minus![]() ![]() ![]() ![]() ![]()
Sometimes you need to combine information of a similar type from more than one table. The set operators UNION, UNION ALL INTERSECT AND MINUS are used. to achieve this. Consider these two queries and their results: PART PLUG SQL > SELECT PART FROM ORDER_LIST , PART SRANKSHAFT TAILPIPE TAILPIPE, The following examples combine the two query results with each of the set operators. <b> Union</b> This statement combines the results with the UNION operator, which eliminates duplicated selected rows: SQL > SELECT PART FROM ORDER LIST UNION 2 SELECT PART FROM ORDER LIST2 PART PLUG PUMP TAILPIPE CRANKSHAFT This statement combines the results with the UNION ALL operators which does not eliminate duplicate selected rows: SQL > SELECT PART FROM ORDER_LIST UNION ALL 2 SELECT PART FROM ORDER LIST2 PART PLUG Note that the UNION operator returns only distinct rows that appear in either
result, while the UNION ALL operator returns all rows. This statement combines the result with INTERSECT operator which returns only those returned by both queries: SQL > SELECT PART FROM ORDER LIST INTERSECT 2 SELECT PART FROM ORDER LIST2 PART TAILPIPE This statement combines the result with the MINUS operator which returns only
those rows returned by the first query but not in the second. 2 SELECT PART FROM ORDER LIST2 PART PLUG The UNION, UNION ALL, INTERSECT and MINUS operators put certain restrictions on the queries they operate on. The queries must select the same number of columns, and the corresponding columns must be of the same type.
|
|
Domain NamesSQL Database Management Systems Relational Database Management System Properties of RDBMS Client Server Computing Oracle Relational Database Database Structure and Space Management SQL Data Types How to Use Data Types? What is Operators and Conditions Character OperatorsOperator Precedence Data Retrieval Using SQL Plus SQL Data Definitions Data Retrieval Using Select SQL Operator Precedence Selecting Rows and Columns The Group by Clause
Having Clause Union, Union all, Intersact and Minus Commands Playing with Numbers Date Functions Example of Date Arithmetic Working with Null Values
Joining Tables and Subqueries Views Synonyms Indexes Clusters Sequences Formatting Query Results with SQL Plus Data Integrity The Optimizer How Oracle Optimizes SQL Statements Evaluating Expression and ConditionsOptimization Hints PL-SQL PL-SQL Architecture Error Reporting Functions Character Functions Composite Data Types PL-SQL Structures How to use PL-SQL Structures Normalization Operator Precedence Cursor Error Handling Database Triggers Types of Triggers Locking Sub Programs Packages New and Improved Data Types Improved Select Statement Advanced Quering Improved Scalability Improved Performance Via Partitioning Object Relational Features Heterogeneous Data Access Improved Security Administration New Data Types Improved Select Statement Changes to the Select Statement Improved Scalability Data Partitioning Oriented Toward Objects Character Functions Creating Object Types Created Nested Tables Oracle8 and Distributed Database Oracle8 Database Management and Security Distributed Database Invoking Export Invoking ImportWeb DesignWeb HostingE Commerce |
| Home | Web Hosting | Web Design | Sitemap |
| Copyright (C) 2007. Web Domain design hosting. All rights reserved. |