From the course: Microsoft SQL Server 2019 Essential Training
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Query information from related tables - SQL Server Tutorial
From the course: Microsoft SQL Server 2019 Essential Training
Solution: Query information from related tables
- [Instructor] In this challenge, we need to combine records from multiple tables for a regional library. And the goal is to get a reverse chronological list of borrowing history and show every member, even the ones that haven't yet borrowed any books. I'm going to start just by taking a look at the three tables that were given. We have one called Members, and I'll just select everything out of that table, that gives me the member ID. This is the primary key for the table, and we get the member's name and their email address. Let's take a look at the Books table now. This one also has a primary key column here for the book ID, and we have the name of the book, as well as the author of the book. And then we can get the borrowing history from the Loans table. This one has a primary key for the loan ID. And then we have two foreign key columns that relate back to the Books table here and the Members table with this column. And we'll finally have the loan date. So this is the date that…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Understand the role of T-SQL1m 59s
-
(Locked)
Use the T-SQL editor6m 4s
-
(Locked)
Create a table with T-SQL5m 28s
-
(Locked)
Solution: Create tables with T-SQL commands3m 48s
-
(Locked)
Add data to a table3m 41s
-
(Locked)
Solution: Add data with T-SQL commands3m 3s
-
(Locked)
Retrieve records with SELECT3m 28s
-
(Locked)
Solution: Query data in a database2m 3s
-
(Locked)
Filter returned results with WHERE1m 51s
-
(Locked)
Sort records2m 42s
-
(Locked)
Solution: Filter and sort data with a query4m 22s
-
(Locked)
Delete records from a table3m 32s
-
(Locked)
Update records in a table3m 4s
-
(Locked)
Solution: Remove and update records in a table6m 22s
-
(Locked)
Join related tables5m 1s
-
(Locked)
LEFT JOIN and RIGHT JOIN2m 16s
-
(Locked)
Solution: Query information from related tables5m 43s
-
(Locked)
Remove a table from the database4m 6s
-
(Locked)
-
-
-
-
-
-