I have to table first one
| type | nbD |
|---|---|
| PC | 2 |
second one
| type | nbF |
|---|---|
| PC | 3 |
| TAB | 2 |
and I want to have something like that
| type | nbD | nbF |
|---|---|---|
| PC | 2 | 3 |
| TAB | null | 2 |
I have to table first one
| type | nbD |
|---|---|
| PC | 2 |
second one
| type | nbF |
|---|---|
| PC | 3 |
| TAB | 2 |
and I want to have something like that
| type | nbD | nbF |
|---|---|---|
| PC | 2 | 3 |
| TAB | null | 2 |
On
What you want to use here is a FULL OUTER JOIN:
SELECT st.type_, ft.nbd, st.nbf
FROM second_table st
FULL OUTER JOIN first_table ft ON ft.type_ = st.type_;
OUTPUT:
type_ nbd nbf
----- --- ---
PC 2 3
TAB null 2
Feel free to refer to this DB Fiddle to check it yourself :)
You can achieve using below query.
Moreover, before asking for help from community, do some research of your own. I believe if you would have searched "SQL joins with example" in google, you would have get this in first or second result. By that way you learn more, and if you get stuck in the process then you have always have the option to ask for help.