We know that in SQL the order the code is executed is:
FROM
WHERE
GROUP
SELECT
Now, in SQL I can write (Example1):
SELECT colA, colB
FROM tableA
UNION
SELECT colA, colB
FROM tableB
WHERE colA > 1
and I can also write (Example2):
SELECT *
FROM (
SELECT colA, colB
FROM tableA
UNION
SELECT colX, colA
FROM tableB
)
WHERE colA > 1
My question is about Example1: the WHERE
condition is on tableB
or on the UNION
of tableA
and tableB
? Unlike Example2, where it's very clear, in Example1 it's not (?).
I didn't find any documentation in any DB that explains this about the UNION
.