Revenue analytics and unit economics Working with joined tables

95. Working with joined tables

Tables aliases

Let’s look at our very first query with join:

SELECT * FROM purchases INNER JOIN users ON purchases.user_id = users.id 

Firstly, in the JOIN condition we specified which table we’re joining – users.

SQL engine will scan every row in the purchases table and determine whether we need to join some rows from the users table to it or not. For that, we need to specify a condition for joining. It always starts with the ON keyword: ON purchases.user_id = users.id.

☝ Since some columns might have the same names in both tables we need to...

“well worth the money”
Sign up and check out 37 free lessons and exercises.

Anatoli Makarevich, author of SQL Habit About SQL Habit

Hi, it’s Anatoli, the author of SQL Habit. 👋

SQL Habit is a course (or, as some of the students say, “business simulator”). It’s based on a story of a fictional startup called Bindle. You’ll play a role of their Data Analyst 📊 and solve real-life challenges from Business, Marketing, and Product Management.

SQL Habit course is made of bite-sized lessons (you’re looking at one atm) and exercises. They always have a real-life setting and detailed explanations. You can immediately apply everything you’ve learned at work. 🚀

“well worth the money”

Fluent in SQL in a month

Master Data Analysis with SQL with real life examples from Product Management, Marketing, Finance and more.
-- Type your query here, for example this one -- lists all records from users table: SELECT * FROM users
Loading chart... ⏳