The difference between using UNION ALL and UNION to display records correctly.
I recently needed data from multiple tables with the same column name to be displayed in the same ROW.
There are two ways to perform this action.
[UNION ALL] and [UNION].
I found that if you use [UNION ALL], it lists all rows but duplicates the top Select statement.
[Examples]
[_00TabOne] had the following data.
IDOrdered
13
15
18
110
[_00TabTwo] had the following data.
IDOrdered
11
12
14
16
17
19
The above two tables have the following columns in common. [Ordered] and [ID].
So, in our SQL Query, we would do something like this.
[UNION ALL]
CFFCS | CarrzSynEdit: | SQL Script

SELECT Ordered FROM _00TabOne UNION all
SELECT Ordered FROM _00TabTwo
where ID = 1 ORDER BY Ordered

Our output will be this.
[Ordered]
1
2
3
3<
4
5
5<
6
7
8
8<
9
10
10<
As you can see, the [_00TabTwo] is duplicated (Highlighted with an arrow), whereas the [_00TabOne] is a single record as it is supposed to be.
So, now let's look at [UNION]
[UNION]
CFFCS | CarrzSynEdit: | SQL Script

SELECT Ordered FROM _00TabOne UNION
SELECT Ordered FROM _00TabTwo
where ID = 1 ORDER BY Ordered

[Ordered]
1
2
3
4
5
6
7
8
9
10

Now, the above is what I needed for my project. I needed this order to display the records from the other tables correctly.