MySQL Union

What is union? Explain with an example.

UNION - The UNION operator is used to combine the result-set of two or more SELECT statements Tables of both the select statement must have the same number of columns with similar data types. It eliminates duplicates.

Syntax:
SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2

Example:
SELECT emp_Name FROM Employees_india
UNION
SELECT emp_Name FROM Employees_USA

Explain the union rules.

1. The number and the order of the columns must be the same in all queries.
2. The data types must be compatible.
3. The columns selected in the different SELECT statements must be in the same order.
MySQL full text searching
MySQL full text searching - use MySQL full text searching capabilities to perform data querying.
MySQL Insert statement
MySQL Insert statement - Insert a single complete row, Insert a single partial row, Insert multiple rows, Insert the result of a query
MySQL manipulating data
MySQL manipulating data - guidelines for updating and deleting data
Post your comment