"if you encounter any errors in SAP, send me a screenshot at pramod@learntosap.com, and I will help you resolve the issue."

SQL UNION Operator

SQL TUTORIALS-

SQL UNION Operator

Introduction-


Trulli Trulli

βœ…In a Simple Word UNION operator is used to combine the result sets of two or more SELECT statements into a single result set...


πŸ’‘ Note: The SQL UNION Operator. SELECT must have the same number of columns. also Columns must have similar data types.

βœ… Syntax Example -



SELECT column1, column2 FROM table1
UNION
SELECT column1, column2 FROM table2;


πŸ’‘ Note: The SQL UNION Operator. Example of two Table 1)-Employee IND. And 2)-Employee US.
Emoji Examples in HTML

πŸ”Έ Example 1-)Table: Employee IND


EmpID Name
1 ANNI
2 BOULT
3 POOJA
Emoji Examples in HTML

πŸ”Έ Example 2-)Table: Employee US


EmpID Name
1 JOHN
2 BOULT
3 ALICE

βœ… Example 1:-



SELECT Name FROM Employees_IND
UNION
SELECT Name FROM Employees_US;

βœ…Result Show :-

Result β†’

Emoji Examples in HTML


Name
ANNI
POOJA
JOHN
BOULT
ALICE

βœ… Example 2: UNION ALL :-Duplicates



SELECT Name FROM Employees_IND
UNION ALL
SELECT Name FROM Employees_US;

βœ…Result Show :-

Result β†’

Emoji Examples in HTML


Name
ANNI
BOULT
POOJA
ALICE

Practice - Yes/No Quiz

1.The UNION operator removes duplicate rows by default.?

2.UNION can be used to combine results from different databases.?

3.Is it true that a FULL OUTER JOIN shows only matched rows from both tables.?


May Be Like Important Link-

-How To Import Data(LSMW) LEGACY SYSTEM MIGRATION WORKBENCH

-Define Condition Type-OBYZ

-Genral Ledger Chart Of Accounts-OBD4

-Document 90039783 saved (no accounting document generated)