Tables
Table 1: Customers
CustomerId |
FirstName |
LastName |
BookId |
1 |
Joe |
Blow |
1 |
2 |
Jane |
Doe |
2 |
3 |
Harry |
Crow |
2 |
4 |
Jeffrey |
Snow |
0 |
Table 2: Books
BookId |
OrderTitle |
1 |
Star Wars |
2 |
Jurassic Park |
3 |
Little Women |
4 |
Tom Sawyer |
Query
SELECT * FROM Customers FULL OUTER JOIN Books ON Customers.BookId = Books.BookId WHERE Customers.CustomerId IS NULL OR Books.BookId IS NULL
Result
id |
firstname |
lastname |
book_id |
id1 |
title |
1 |
Jeffrey |
Snow |
0 |
NULL |
NULL |
NULL |
NULL |
NULL |
NULL |
3 |
Little Women |
NULL |
NULL |
NULL |
NULL |
4 |
Tom Sawyer |
© 2019, Alejandro G. Carlstein Ramos Mejia. All rights reserved.