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

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