Re: Union query
Posted in 1998
Girish Kagrana wrote:
> I have two queries as follows
>
> query-1
> -------
>
> select tabid,"from_1st_select" from systables where tabid < 4
> union
> select tabid,"from_2nd_select" from systables where tabid < 4>
> query-1-output
> --------------
> tabid (constant)
>
> 1 from_1st_select
> 1 from_2nd_select
> 2 from_1st_select
> 2 from_2nd_select
> 3 from_1st_select
> 3 from_2nd_select
>
> query-2
> -------
>
> select "from_1st_select" from systables where tabid < 4
> union
> select "from_2nd_select" from systables where tabid < 4
>
> query-2-output
> --------------
>
> (constant)
>
> from_1st_select
> from_2nd_select
>
> Question : the 1st query returns 6 rows, that is ok,
> why 2nd query is returning 2 rows, why not 6 rows
A union select removes all duplicate rows...
--
======================================================================
Pete Frehner
Praeda Management Systems Voice: (519) 685-3350 xt 26
112-920 Commissioners Rd. E. Fax: (519) 685-3009
London, Ontario CANADA N5Z 3J internet: pfrehner@praeda.com
======================================================================