Syntax\n------\n\nSELECT ...\n(INTERSECT [ALL | DISTINCT] | EXCEPT [ALL | DISTINCT] | UNION [ALL | DISTINCT]) SELECT ...\n[(INTERSECT [ALL | DISTINCT] | EXCEPT [ALL | DISTINCT] | UNION [ALL | DISTINCT]) SELECT ...]\n[ORDER BY [column [, column ...]]]\n[LIMIT {[offset,] row_count | row_count OFFSET offset}]\n\nDescription\n-----------\n\nMariaDB has supported INTERSECT (as well as EXCEPT) in addition to UNION since MariaDB 10.3.\n\nAll behavior for naming columns, ORDER BY and LIMIT is the same as for UNION.\n\nINTERSECT implicitly supposes a DISTINCT operation.\n\nThe result of an intersect is the intersection of right and left SELECT results, i.e. only records that are present in both result sets will be included in the result of the operation.\n\nINTERSECT has higher precedence than UNION and EXCEPT (unless running running in Oracle mode, in which case all three have the same precedence). If possible it will be executed linearly, but if not, it will be translated to a subquery in the FROM clause:\n\n``sql\n(SELECT a,b FROM t1)\nUNION\n(SELECT c,d FROM t2)\nINTERSECT\n(SELECT e,f FROM t3)\nUNION\n(SELECT 4,4);\n`\n\nwill be translated to:\n\n`sql\n(SELECT a,b FROM t1)\nUNION\nSELECT c,d FROM\n  ((SELECT c,d FROM t2)\n   INTERSECT\n   (SELECT e,f FROM t3)) dummy_subselect\nUNION\n(SELECT 4,4)\n`\n\nParentheses\n\nParentheses can be used to specify precedence.\n\nParentheses cannot be used to specify precedence.\n\nMariaDB starting with 10.5.0\n\nALL/DISTINCT\n\nINTERSECT ALL and INTERSECT DISTINCT . The ALL operator leaves duplicates intact, while the DISTINCT operator removes duplicates. DISTINCT is the default behavior if neither operator is supplied.\n\nDISTINCT` is the only behavior available.\n\nExamples\n--------\n\n(SELECT e_name AS name, email FROM employees)\nINTERSECT\n(SELECT c_name AS name, email FROM customers);\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/set-operations/intersect