I have two select statements.
SELECT ...
UNION
SELECT ...
If I run the first SELECT, the data comes back fine.
If I run the second SELECT, the data comes back fine.
If I run both at the same time using a UNION, the first row is always a NULL.
I don’t get it. Anyone know why this could be causing an issue?
There is a NULL row in your data. What is hapening is that the
unionis doing a sort, which is bringing the NULL up to the first row.If you want to eliminate the NULL value, use a
whereclause.If you want your query to be more efficient by not eliminating duplicates, using
union all.