Re: joining tables - Mailing list pgadmin-support

From TedJones
Subject Re: joining tables
Date
Msg-id 1567508518990-0.post@n3.nabble.com
Whole thread Raw
In response to Re: joining tables  (Patrick Headley <pheadley@linxco-inc.com>)
Responses Re: joining tables
Re: joining tables
List pgadmin-support
Hi Patrick

Thanks for your response. The tables that I gave were just an example and
there is no relevance in the friend/yes or names/contact details in
different tables.

To clarity, another example would be three tables - shop1, shop2 and shop3.
Each would have products so that would be a common column but product price
may also be a common column. However, there would be also different column
names for each shop. (columns with same names would be of the same data
type).

I have no control over the three tables that I get as csv files. It should
be easy enough, if needed to add a primary key column (to each?) after
reading in the csv files into tables.

So, generally, what I am trying to achieve is to combine three tables into
one table where some of the columns are the same and some are not. e.g table
1 with 12 columns; table 2 with 10 columns where 4 are the same as in table
1; table 3 with 4 columns where 1 is the same as in table 1 and 1 the same
as in table 2. The number of columns in the result table would then be 12
(table 1) +  6 (new ones from table 2) + 2 (new ones from table 3) = 20
columns.

Usually the data rows from each table will be different but not always. If
data in a column common to all three tables e.g product name, was the same
from all tables i.e. same product name then all the information about that
product from the three tables would be in all the columns for that data row.
I hope that’s clear. i.e. the difference between example1 and example2 in my
original question.

In this was in reverse it would start with the large result table and use
three SELECT statements to create the three tables.

Thanks
Ted Jones





--
Sent from: https://www.postgresql-archive.org/PostgreSQL-pgadmin-support-f2191615.html



pgadmin-support by date:

Previous
From: Patrick Headley
Date:
Subject: Re: joining tables
Next
From: "Holger Kopp-Musick"
Date:
Subject: Negative values for obj_id: SELECT statements throwing errors inquery editor