union/union all运算:将查询的返回组合成一个结果, union all不过滤重复。
- SELECT product_id FROM order_items
- UNION
- SELECT product_id FROM inventories;
- SELECT location_id FROM locations
- UNION ALL
- SELECT location_id FROM departments;
intersect运算:返回查询结果中相同的部分。
- SELECT product_id FROM inventories
- INTERSECT
- SELECT product_id FROM order_items;
- SELECT product_id FROM inventories
- MINUS
- SELECT product_id FROM order_items;