Skip to main content
Solved

Full outer join between two tables


rvgfox
Problem Solver
Forum|alt.badge.img+4

I’ve two tables, A and B, and I want a full outter join to obtain a table C like in the image:

In T-SQL it would be:

SELECT  COALESCE(A.Id, B.Id) AS Id

       ,A.ValueA AS ValueA

       ,B.ValueB AS ValueB

FROM TableA AS A

    FULL OUTTER JOIN TableB AS B

ON A.Id=B.Id

 

Is it the only way to use a custom view?

Best answer by Thomas Lind

I don’t know if this is entirely relevant, but here is how I got it to show what you wanted.

I made the two tables with custom data.

Then I made a Add Related Records insert. I set it up like so.

Notice that the record condition is set to not exists.

Then I related TableA and TableB with the ID field and added ValueB as a lookup to fill the data.

Here is the result.

 

View original
Did this topic help you find an answer to your question?

daniel
TimeXtender Xpert
Forum|alt.badge.img+7
  • TimeXtender Xpert
  • October 25, 2023

Dear @rvgfox ,

In my opinion this is the only time when you really need a custom view.
If you need to ‘Blow up’  / create a carthesian product of the table by (outer) joining, because your goals is to increase the amount of records then there is no other way that I know of to do this.

 

Lookups never create more records in the destination table.

 

Hope this helps

 

= Daniel


rvgfox
Problem Solver
Forum|alt.badge.img+4
  • Problem Solver
  • October 26, 2023

Thanks @daniel 

 

My approach it’s to use a “simple custom view” like this:

SELECT Id FROM A

UNION

SELECT Id FROM B

And create a table based on this view and make the lookups and transformations needed.

What do you think?


Bernarddb
TimeXtender Xpert
Forum|alt.badge.img+5
  • TimeXtender Xpert
  • October 26, 2023

Hi @rvgfox You could use a junk dimension table. take the id's from the both tables. and then use lookups to join the fields to the table if you don't want to keep it in TimeXtender native


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • October 26, 2023

Hi @rvgfox 

Any type of outer join are only possible in custom views currently.

When you map two tables together with the same structure they get a union behind the scenes.

It will not give the look you have in the first post, it will be like this.

Id ValueA ValueB
1 A null
2 B null
3 B null
4 C null
5 null F
6 null G

 

So using an custom view is preferable.


daniel
TimeXtender Xpert
Forum|alt.badge.img+7
  • TimeXtender Xpert
  • October 26, 2023

Personally, if I can avoid custom view I will. 

For a union I would not use a custom view as this can be done in TX native. 

By creating a table and mapping the fields from the table in destination columns you want them to be:

 


Then you can still do the lookups if you want and TX keeps tracking the data lineage and such as it normally would. Mistakes in the parameters can be made very quicky and for some views I might take a while.

In the case of a full outer join I'm not use it will work the same as unioning the table and then doing lookups though. If you need to create a carthesian product because that is what you need, then use a full outer join or a cross apply. If not, then my go to is to fix it ‘TimeXtender​​​​​​ Natively’ 

= Daniel


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • October 26, 2023

I don’t know if this is entirely relevant, but here is how I got it to show what you wanted.

I made the two tables with custom data.

Then I made a Add Related Records insert. I set it up like so.

Notice that the record condition is set to not exists.

Then I related TableA and TableB with the ID field and added ValueB as a lookup to fill the data.

Here is the result.

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings