Javatpoint Logo
Javatpoint Logo

MariaDB UNION Operator

In MariaDB database, UNION Operator is used to combine the result sets of two or more SELECT statements. It removes duplicate rows between the various SELECT statements.


Note: Each SELECT statement within the UNION operator must have the same number of fields in the result sets with similar data types.

Return Single Field using UNION Operator

Let's take an example of MariaDB UNION Operator that returns one field from multiple SELECT statements. (Both tables having a same common field).

We have two tables "Student" and "Students".

Student Table:

MariaDB Union all operator 1

Students Table:

MariaDB Union all operator 2


MariaDB Union all operator 3

It shows the student_name from both table where duplicates names are removed.

UNION Operator with ORDER BY Clause

Use UNION operator with ORDER BY clause to retrieve multiple columns from both table.


MariaDB Union all operator 4

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA