From the course: SQL Server Fundamentals: Master Basic Query Techniques
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Subqueries
From the course: SQL Server Fundamentals: Master Basic Query Techniques
Subqueries
- [Instructor] As we've discussed, one of the functions of inner joins is that they can be used to filter results sets, but there is another method that we can use to achieve this called a subquery. So we're going to use a subquery to get us the results we need to get all of the names for customers who live in Boston. So first let's start by running a query that will get us all of the customer names. And we know from our previous examples that that's going to be from the customer table. So we're going to select star from dbo.customer, and we're going to go ahead and give this a table alias. So let's run that and look at our data once again. We don't have the city name in this table so we can't filter on that condition right now. But if we can get access to information from the city_state_zip table, we can apply those filters. So what we're going to do is we're going to select star from dbo.city_state_zip.…
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.