Professional Documents
Culture Documents
Menu
Answer:
UNION and UNION ALL: Used to combine the result set of 2 or more SELECT
statements.
UNION sql statement returns sorted result set with unique (UNION effectively
performs SELECT DISTINCT) rows.
UNION ALL sql statement returns unsorted result set including duplicate rows.
NOTE:
To use UNION & UNION ALL, number of columns, data types and the order of the
columns must be same in each select statement. However, number of equal
rows is not required.
If all the rows are already unique, use UNION ALL instead of UNION, it gives faster
results as UNION ALL doesn’t perform SELECT DISTINCT. ORDER BY clause can be
used to sort the result.
NAME POST
Lisa Manager
JAVA
NAME POST
On performing union query on table C++ and Java following will be the result
NAME POST
Lisa Manager
On performing Union All query on table C++ and Java following will be the result
NAME POST
Lisa Manager
To Focus:
ORDER BY should be used only on the last select statement in the UNION ALL queries
otherwise it will throw an error.
UNION Vs JOIN
Related Posts:
SQL Database
sql union, sql union all
What is Use of Private Constructor in C# ? Scenarios Example
What is Comparable and Comparator in java?
Leave a Comment
Name *
Email *
Website
Post Comment
C
C++ Basic
C++ Advanced
C++ Programming
C# Interview Questions
C# Basic
C# Advanced
C# Multi-threading
C# Programming
C# program exercises
Java Interview Questions
Core Java
Java Collections
Java Multithreading
Java Notes
Java Tutorial
MCQ-C++
MCQ-Java
MCQ-SQL
MCQs Algorithms and Data Structure
Others
C NOTES
SQL Database
Design Patterns and Principles
Networking General
UML Diagram
Mathematical Puzzles
Author
OPEN
Recent Posts
SUBSCRIBE
© 2019 Interview Sansar • Powered by GeneratePress