SQL FULL OUTER JOIN in DB2 for i SQL |
Full Outer Join
A full outer join returns matching rows from both tables along with nonmatching rows from both tables.
Syntax
SELECT column_name(s) FROM table1 FULL OUTER JOIN table2 ON table1.column_name = table2.column_name
Reference Tables for understanding FULL OUTER JOIN
Example using SQL FULL OUTER JOIN
Perform FULL OUTER JOIN on Table STUDENT and COURSE based on field ROLLNO
SELECT S.ROLLNO, S.NAME, S.GENDER, C.COURSEID, C.COURSENAME FROM student s FULL OUTER JOIN course c ON s.rollno = c.rollno
Result:
ROLLNO NAME GENDER COURSEID COURSENAME 1 AMIT M C1 IT 2 AMAN M C2 EC 3 HEMANT M - - 4 ANNAMALAI M - - 5 KESHAV M - - - - - C3 EL