Re: How to show Null expression in SQL query ?
Posted in 1998
In article <74s5i0$j7h$1@news.xmission.com>, <rfurdzik@paulweiss.com> wrote:
>
> I need to create an union query, so number and type of column must be the=20
>same=2E I want to replace missing columns with NULL's, so client applicatio=
>n will=20
>show nothing for those missing columns=2E
>
One way:
create temp table dummy_tab ( null_int integer, b integer ) ;
insert into dummy_tab ( b ) values ( 1 ) ;
select a, b, c, d, e, f
from tab_1
union
select p, q, r, null_int, s, t
from tab_2, dummy_tab
- in the case that 'd' is the column missing from tab_2, and 'd' is of
type integer. The point is that 'null_int' is a NULL of type integer
and so the two selects can be unioned together. You can do the same sort
of thing so select other nulls columns of whatever datatype you need.
Hope this helps,
- Paul