>* this return X >SELECT F1 X FROM T1; >UNION ALL; >SELECT F2 Y FROM T2 > >* this return Y >SELECT F1 X FROM T1; >UNION ; >SELECT F2 Y FROM T2 >I'd write the queries like this and be happy all day long that I got consistent results:
* this returns X SELECT F1 X FROM T1; UNION ALL; SELECT F2 FROM T2 * this returns X SELECT F1 X FROM T1; UNION ; SELECT F2 FROM T2 * this returns X SELECT F1 X FROM T1; UNION ALL; SELECT F2 X FROM T2 * this returns X SELECT F1 X FROM T1; UNION ; SELECT F2 X FROM T2It just doesn't make much sense that you'd give alternate aliases (X in one statement and Y in another) to the columns between the select statements. For non-trivial queries it would be much harder for another developer following behind you to understand/modify/debug/ the SQL code.