UNION聯集
UNION可以多次使用,使用UNION時的屬性數目都要一樣,資料型態也要一樣
SELECT `name`
FROM `employee`
UNION
SELECT `client_name`
FROM `client`;
列出的表格名字會是第一個SELECT的屬性名稱,也可以使用AS
將列出的屬性名稱做更改的動作
SELECT `emp_id`,`name`
FROM `employee`
UNION
SELECT `client_id`,`client_name`
FROM `client`;
AS將列出的屬性名稱做更改的動作
SELECT `emp_id` AS `total_id`, `name` AS `total_name`
FROM `employee`
UNION
SELECT `client_id`,`client_name`
FROM `client`;
SELECT `salary`
FROM `employee`
UNION
SELECT `total_sales`
FROM `works_with`;
AS `total_money`
SELECT `salary` AS `total_money`
FROM `employee`
UNION
SELECT `total_sales`
FROM `works_with`;