Home » MariaDB Intersect Operator

MariaDB Intersect Operator

by Online Tutorials Library

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

MariaDB Intersect operator 1

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:

MariaDB Intersect operator 2

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:

MariaDB Intersect operator 3

Note: You can also use INTERSECT operator with multiple expressions.

Next TopicMariaDB Export

You may also like