INTERSECT示例 以下语句将结果与INTERSECT
运算符组合,该运算符仅返回由两个查询返回的唯一行:
SELECT product_id FROM inventorys INTERSECT SELECT product_id FROM order_items ORDER BY product_id;
MINUS示例 以下语句将结果与
MINUS
运算符相结合,该运算符仅返回由第一个查询返回但不是第二个查询返回的唯一行:SELECT product_id FROM inventoryments MINUS SELECT product_id FROM order_items ORDER BY product_id;UNION ALL实施例 的
UNION
操作者仅返回出现在任一结果不同的行,而UNION
ALL
操作者将返回所有行。该UNION
ALL
运营商不消除重复选择的行:SELECT product_id FROM order_items UNION SELECT product_id FROM库存 ORDER BY product_id; SELECT location_id FROM locations UNION ALL SELECT location_id FROM departments ORDER BY location_id;