- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between UNION and UNION ALL in DB2
The UNION in DB2 is used to merge two or more SELECT statements. The SELECT statements can be on a single table or on multiple tables. Each SELECT statement is processed individually and their results are combined to give us the final result rows.
The UNION statement will eliminate the duplicate rows appearing as a result of SELECT statements. If we want to retain the duplicate rows, then we can use the UNION ALL statement.
For example, if we want to extract all ORDER_ID with ORDER_TOTAL greater than 1000 in ORDERS and ORDERS_HIST table, we can use the below query with a UNION statement.
SELECT ORDER_ID FROM ORDERS WHERE ORDER_TOTAL > 1000 UNION SELECT ORDER_ID FROM ORDERS_HIST WHERE ORDER_TOTAL > 1000
- Difference Between Structure and Union
- Difference between Structure and Union in C
- Difference between Join and union in SQL
- Difference between Structure and Union in C Program
- What is the difference between DB2 JOIN and UNION? Explain with the help of an example
- Union in C
- State the difference between structure and union with suitable example in C language
- How to generate data with Union ALL and Insert ALL in Oracle?
- Anonymous Union and Structure in C
- Union Method in C#
- Union() function in Python
- C# Queryable Union Method
- Union Type in PHP 8
- Explain Union process in DFA