Re: joining tables

2019-09-03 Thread Avin Kavish
yes, what you need is a full outer join. How are your actual results different from the expected ones? On Wed, Sep 4, 2019 at 4:18 AM Michel Feinstein wrote: > Also, be aware that this is NOT the postgresql email list, but the pgAdmin > email list, you would get a lot more help about SQL there.

Re: joining tables

2019-09-03 Thread Michel Feinstein
Also, be aware that this is NOT the postgresql email list, but the pgAdmin email list, you would get a lot more help about SQL there. On Tue, Sep 3, 2019, 19:44 Jack Royal-Gordon wrote: > Let me step back a bit, as I realize upon further reflection that the > first method will not work. > > As f

Re: joining tables

2019-09-03 Thread Jack Royal-Gordon
Let me step back a bit, as I realize upon further reflection that the first method will not work. As far as the issue about two “Ted” records, read it as though I said two “Ted D” records. It refers to two records in the same table with the same key value. If “Ted D” appeared twice in table 1 a

Re: joining tables

2019-09-03 Thread Patrick Headley
Not having unique IDs from the source tables will present a problem in that you could have more than one record in one of the tables with the same data. It looks like you will need to determine the fields that make each row unique but common in all three tables. Then, you can match up records

Re: joining tables

2019-09-03 Thread TedJones
Hi Jack I'm not sure if I understand your comment about two 'Ted' fields and duplication of rows. In the example below there is 'Ted' twice in Table3 1 and 3 and must appear twice as I've shown in the result as the data in the rest of the row is different. I agree with no duplication of rows if al

Re: joining tables

2019-09-03 Thread Jack Royal-Gordon
Hi Ted, In essence, you want to merge the three tables, removing records that are duplicated by another table, right? Here are two approaches: 1) SELECT DISTINCT (field list) FROM (SELECT * from table1 UNION SELECT * from table2 UNION SELECT * from table 3). This will remove all duplicates, re

Re: joining tables

2019-09-03 Thread TedJones
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

Re: joining tables

2019-09-02 Thread Patrick Headley
The first thing I noticed is that there is no primary key field on Names. If Friend is a child table then you will use a LEFT OUTER JOIN. Friend will need a foreign key field that has values matching the primary key field in Names. Friend should also have it's own primary key field. If you ar

joining tables

2019-09-02 Thread TedJones
I'm having problems joining 3 tables to provide a 4th table in the correct format. I believe I need a FULL OUTER JOIN but does not give the result that I require.See below: Example 1 Table: NamesTable: Friend NameTel email PostCodeNamefrien