Subject Re: [firebird-support] How to prevent doubled rows in query?
Author Helen Borrie
At 09:51 AM 23/06/2005 +0000, you wrote:
>I have two tables containing NAME and IDs...
>In both table same NAMEs can appear!
>
>I use select query like:
>
>SELECT DISTINCT NAME1 AS NAME,ID AS IDD FROM VOZACI
>UNION
>SELECT DISTINCT NAM2 AS NAME,ID AS IDD FROM UTOVARIVACI
>ORDER BY 1
>
>
>But, if there are same names in both tables I get doubled row in
>result set. Can I prevent rows to be doubled?

UNION (without the ALL keyword) should eliminate duplicate rows. Of
course, if you have the same names with different id's, you will get one
row for each combination of name + id. If it is only the names you are
interested and you want to avoid duplicate names, don't include id in the
query.

./heLen