78
MariaDB INTERSECT Operator
INTERSECT Operator is used to return intersection of 2 or more tables. If a record exists in both tables, it will be included in the INTERSECT results. Otherwise, it will be omitted from the INTERSECT results.
Syntax:
Image representation
Note: MariaDB does not suppoort INTERSECT operator but you can see the same thing by using IN operator to simulate the INTERSECT query as follows:
Return Single Field using INTERSECT Operator
Following is a general query for INTERSECT operator but it will not be supoported in MariaDB.
Use the following one:
Output:
It shows only common names between both the tables “Students” and “Student”.
INTERSECT Operator with WHERE Clause
Following is a general query for INTERSECT operator but it will not be supoported in MariaDB.
Use the following syntax:
Output:
Note: You can also use INTERSECT operator with multiple expressions.
Next TopicMariaDB Export