Let’s say you have 2 tables:
ID Name
1 Smith
2 Novak
3 Tarantino
and the second table
ID Cash
2 300
3 490
4 500
INNER JOIN
will join records that have match in both tables, i.e. in the result table only ID
2 and 3 will be included, because they have match.
Result would look like:
ID Name Cash
2 Novak 300
3 Tarantino 490
OUTER JOIN
on the other hand, will match everything, irrespectively whether they have match or not. If record doesn’t have match, then value corresponiding to certain row will be NULL
, i.e. Smith will have NULL
in Cash
column and record corresponding to 500 in Cash
column will have NULL
in Name
column.
Result would look like:
ID Name Cash
1 Smith NULL
2 Novak 300
3 Tarantino 490
4 NULL 500
1
solved What basic example I can give for inner join and outer join in SQL? [duplicate]