From the course: SQL: Data Reporting and Analysis
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Merge data across tables with IN - SQL Tutorial
From the course: SQL: Data Reporting and Analysis
Merge data across tables with IN
- [Instructor] I want to show you another way of using data from two tables. It's not a join. It's not a union. And it's a bit of a hack, to be honest. I wouldn't generally use it. But if you are looking at queries that other people have written, you may have come across this. So you need to know that it exists. So we're looking at the customer table where the first name is Mary, and you can see we've got MARY SMITH down here, and she has a customer ID of 1. And what we're going to do is we're going to use this query to filter another query. Now, let's say, we just returned the customer ID of Mary, which as we know is 1. And then what we're going to say is SELECT everything FROM the rental table. So we want to see all the transactions that have happened, WHERE the customer_id is IN. We've seen the IN keyword before. But last time, we supplied a set of text items in the bracket. I think it was Penelope Nick and the…
Contents
-
-
-
-
-
-
(Locked)
Make your queries faster1m 47s
-
(Locked)
Understand SQL indexes and keys7m 16s
-
(Locked)
EDIT: Visualize your database7m 58s
-
(Locked)
Merge data across tables with JOIN5m 2s
-
(Locked)
Understand SQL JOINS4m 16s
-
(Locked)
Combine rows with SQL UNION4m 49s
-
(Locked)
Merge data across tables with IN2m 11s
-
(Locked)
Select from a selection with subqueries2m 56s
-
(Locked)
Challenge: Join tables1m 4s
-
(Locked)
Solution: Join tables4m 37s
-
(Locked)
-
-