Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL Joins FdSc in ICT.

Similar presentations


Presentation on theme: "SQL Joins FdSc in ICT."— Presentation transcript:

1 SQL Joins FdSc in ICT

2 Structure – using student#
Borrower 7 (Pratton) has borrowed book 9 (Doing Postgraduate Research) Note: Illustrations of tables are shortened to fit on the slides

3 An inner join returns all rows that result in a match
SELECT lastname,loans.bookid FROM borrower INNER JOIN loans ON borrower.borrowerid = loans.borrowerid

4 A LEFT JOIN returns all rows from the LEFT table even if there is no match in the RIGHT table
SELECT lastname,loans.bookid FROM borrower LEFT JOIN loans ON borrower.borrowerid = loans.borrowerid Left table Right table

5 A RIGHT JOIN returns all rows from the RIGHT table even if there is no match in the LEFT table
SELECT books.title,loans.bookid FROM loans RIGHT JOIN books ON loans.bookid = books.bookid Left table Right table

6 A three way LEFT join SELECT books.title, borrower.lastname FROM books
LEFT JOIN loans ON books.bookid = loans.bookid LEFT JOIN borrower ON loans.borrowerid = borrower.borrowerid


Download ppt "SQL Joins FdSc in ICT."

Similar presentations


Ads by Google