Skip to content
Advertisement

FULL OUTER JOIN (or UNION) on 2 tables

I’m facing a SQL request issue. I’m not a SQL expert and I would like to understand my mistakes. My use case is to get all records of the first table + records of the second table that are not present in the first table. I’ve got 2 tables like this :

First table “T-Finance par jalon ZOHO” (with 20 columns):

Second table “T-Finance par jalon EVERWIN” (with 20 columns):

Wanted result is :

So I suppose a full outer join is the solution but I don’t know why it does not work as attended. I tried a lot of things but record (21021287, ACT, 50000) is never present in final result.

here is one of the request I tried:

I also tried with a UNION and it works but the problem is I don’t know how to get all others informations (columns) of each row. Because if I add others columns into SELECT statement, UNION will not detect duplicates :

Thanks for your help.

Advertisement

Answer

I assume you want minimum value of Num_Ligne when matching rows are found. Full join version, provided your DBMS supports least. Otherwise you can do it with a CASE expression.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement