What is the SQL UNION Operator and how it can be used with the database?
The SQL UNION Operator is used to combine the data from multiple SQL Select Statetements.
SQL UNION Operator Example:
Lets assume that you have 2 tables for customers. One table contains all customers from USA and other contains all customers from INDIA. You want to get name and email addresses from both the tables.
Use following syntax of sql union operator for that case:
SELECT name, email FROM customer_usa
SELECT name, email FROM customer_india;
As you can see above, UNION Operator is used to combine the resultset of two SQL Select statements. Make sure that both SQL Statement must have same column counts and same data types in respective columns.