Like SQL standard, MySQL UNION allows you to combine two or more result sets from multiple tables together. The syntax of using MySQL UNION is as follows:
SELECT statement UNION [DISTINCT | ALL] SELECT statement UNION [DISTINCT | ALL]Suppose you want to combine customers and employees infomation into one result set, you use the following query:
SELECT customerNumber id, contactLastname name
FROM customers
UNION
SELECT employeeNumber id,firstname nameFROM employees
No comments:
Post a Comment