Unions in MariaDB are used to combine the result of two or more SELECT statements. However, there are rules that need to be followed when using unions:
1. Each SELECT statement within the UNION must have the same number of columns.
2. The columns must also have similar data types.
3. The columns in each SELECT statement must also be in the same order.
Here is a basic example of how to use unions in MariaDB:
```
SELECT column_name FROM table1
UNION
SELECT column_name FROM table2;
```
This will return a list of the distinct values of `column_name` from both `table1` and `table2`.
If you want to select all values from both tables, including duplicates, you can use `UNION ALL`, like this:
```
SELECT column_name FROM table1
UNION ALL
SELECT column_name FROM table2;
```
This will return all values of `column_name` from both `table1` and `table2`, including duplicates.
It’s important to note that the UNION operator only returns distinct values. UNION ALL returns all values.
Also, the result-set of a UNION is sorted ascending by default. If you want to change the order you can add an ORDER BY statement as follows:
```
SELECT column_name FROM table1
UNION
SELECT column_name FROM table2
ORDER BY column_name DESC;
```
This will return a list of the distinct values of `column_name` from both `table1` and `table2`, sorted in descending order.