-- INTERSECT / EXCEPT need MySQL 8.0.31+ (or MariaDB 10.3+). -- IN / NOT IN alternatives are shown where useful. -- Performance tip: returns.order_detail_id has no index by default.