From the course: Microsoft SQL Server 2022 Essential Training
Unlock this course with a free trial
Join today to access over 24,100 courses taught by industry experts.
Solution: Query information from related tables - SQL Server Tutorial
From the course: Microsoft SQL Server 2022 Essential Training
Solution: Query information from related tables
(upbeat music) - [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 member's table with this column, and we'll finally have the loan date, so this is…
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
-
-
-
-
-
-
-
Understand the role of T-SQL2m 40s
-
(Locked)
Use the T-SQL editor6m 49s
-
(Locked)
Create a table with T-SQL6m 33s
-
(Locked)
Solution: Create tables with T-SQL commands3m 46s
-
(Locked)
Add data to a table4m 58s
-
(Locked)
Solution: Add data with T-SQL commands3m 4s
-
(Locked)
Retrieve records with SELECT4m 3s
-
(Locked)
Solution: Query data in a database2m 7s
-
(Locked)
Filter returned results with WHERE3m 12s
-
(Locked)
Sort records2m 54s
-
(Locked)
Solution: Filter and sort data with a query4m 27s
-
(Locked)
Delete records from a table4m 31s
-
(Locked)
Update records in a table2m 3s
-
(Locked)
Solution: Remove and update records in a table6m 11s
-
(Locked)
Joining related tables4m 32s
-
(Locked)
Solution: Query information from related tables5m 33s
-
(Locked)
Remove a table from the database5m 7s
-
-
-
-
-
-