B
Bill Sturdevant
I have a table that may or may not have any records in
it. I need to do a Union Query, but the Union Query only
works if there is at least one record in the table:
SELECT ID, Field1 From Table1
UNION SELECT 0 as ID, "<ZeroValue>" as Field1 FROM Table1
ORDER BY Field1;
When there is at least one record in Table1 I get the
following:
ID Field1
0 <ZeroValue>
-238726 Value from record 1
BUT, when table1 has no records, I get no results. What I
need to get is the following:
ID Field1
0 <ZeroValue>
How do I do this?
I have discovered that if I change the query to the
following it works:
SELECT ID, Field1 From Table1
UNION SELECT 0 as ID, "<ZeroValue>" as Field1 FROM
AnyOtherTableWithRecords
ORDER BY Field1;
But I do not like this because how can I know that
AnyOtherTableWithRecords might someday have 0 records.
it. I need to do a Union Query, but the Union Query only
works if there is at least one record in the table:
SELECT ID, Field1 From Table1
UNION SELECT 0 as ID, "<ZeroValue>" as Field1 FROM Table1
ORDER BY Field1;
When there is at least one record in Table1 I get the
following:
ID Field1
0 <ZeroValue>
-238726 Value from record 1
BUT, when table1 has no records, I get no results. What I
need to get is the following:
ID Field1
0 <ZeroValue>
How do I do this?
I have discovered that if I change the query to the
following it works:
SELECT ID, Field1 From Table1
UNION SELECT 0 as ID, "<ZeroValue>" as Field1 FROM
AnyOtherTableWithRecords
ORDER BY Field1;
But I do not like this because how can I know that
AnyOtherTableWithRecords might someday have 0 records.