Re: SQL query...

From: "Mario Weilguni" <mweilguni(at)sime(dot)com>
To: <jerome(at)gmanmi(dot)tv>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL query...
Date: 2003-02-19 13:38:53
Message-ID: 003b01c2d81c$3e716d20$8f01c00a@icomedias.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>if i have 5 tables and all of it has column X and i wanted to get unique
>values in column X for all tables..

>can i do it in one query?

sure. this is one way to do this:
select distinct foo.X from (
select X from table1
union
select X from table2
....
) as foo;

if the values are unique within every table, then you might want to omit the
surrounding select.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mark Cave-Ayland 2003-02-19 13:55:01 Re: 7.3.1 takes long time to vacuum table?
Previous Message Oliver Elphick 2003-02-19 13:36:19 Re: How do I get the database connections to close down?