Please note, this is a STATIC archive of website www.javatpoint.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
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.

Syntax:

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

Output:

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.

Output:

MariaDB Union all operator 4





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA