Re: SQL query... - Mailing list pgsql-general

From Mario Weilguni
Subject Re: SQL query...
Date
Msg-id 003b01c2d81c$3e716d20$8f01c00a@icomedias.com
Whole thread Raw
In response to SQL query...  (jerome <jerome@gmanmi.tv>)
Responses Re: SQL query...
Re: SQL query...
List 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.



pgsql-general by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: How do I get the database connections to close down?
Next
From: "Mark Cave-Ayland"
Date:
Subject: Re: 7.3.1 takes long time to vacuum table?