The MySQL UNION operator is allow you to combine the result-set of two or more SELECT statements together if SELECT statement have the same number of columns with similar data types and it should be in the same order.
To combine the result-set of two or more SELECT statements together, use the following syntax:
Parameters:
tablename: The table name from which you want to perform UNION
operator.
UNION: To combine the result-set of two or more SELECT statements.
Note:
In the above example, the UNION
operator will return all distinict records from "tblCustomer" and "tblCustomerLoan" table.
You can use MySQL Command Line Client to use UNION
operator to combine the result-set of two or more SELECT statements together. It will look like this:
Note:
In the above example, the UNION ALL
operator will return all records from "tblCustomer" and "tblCustomerLoan" table.
You can use MySQL Command Line Client to use UNION ALL
operator to combine the result-set of two or more SELECT statements together. It will look like this: