Filling holes in union columns
Posted in 1999
Topics: Data Types & Schema Design
I have two tables A with columns a, b and c; and B with columns a and
b. Columns A.a and B.a are the same data type and A.b and B.b are also
the same data type.
I have a select similar to the following
select a, b, c from A
union
select a, b, ?? from B
Using some other database products I'd just replace ?? with null and it
would work. How do you do this with Informix? I've tried some other
ways to get nulls into the ?? column but get data type conflicts etc.
Cheers
It depends on the datatype of A.c
It it's a char field ?? can be "" (two quotes).
It it's some numeric datatype (serial, smallint, integer, decimal...)
you can use 0 (zero).
It it's a date field you can use today.
If it's a datetime you can use current with an appropriate qualifier
(year to minute or whatever the datatype of A.c is specified as).
It's a little harder than using null, but not much.
On Wed, 31 Mar 1999 01:00:38 -0500, Jay Walters
<jwalters@computer.org> wrote:
>I have two tables A with columns a, b and c; and B with columns a and
>b. Columns A.a and B.a are the same data type and A.b and B.b are also
>the same data type.
>
>I have a select similar to the following
>
>select a, b, c from A
> union
>select a, b, ?? from B>
>Using some other database products I'd just replace ?? with null and it
>would work. How do you do this with Informix? I've tried some other
>ways to get nulls into the ?? column but get data type conflicts etc.
>
>Cheers
Nils Myklebust
NM Data AS
Norway
E-mail: Nils.Myklebust@nmdata.com
FAQ at: http://www.iiug.org/techinfo/faq/faq_top.html
(Now with ODBC info under "Third party products".)