SQL union and where clause
Sometimes there is a need of filtering result of a union of several tables. This is fairly easy task that could vary between different RDBMS systems. This a standart SQL code that is working on MySQL and Oracle.
SELECT *
FROM
(
SELECT 1 AS `col` UNION
SELECT 2 AS `col` UNION
SELECT 3 AS `col` UNION
SELECT 4 AS `col`
) AS `result`
WHERE `result`.`col` > 2
Result:
'col'
3
4