Categories
Analysis Analytics Business Decisions Thoughts Tips

SQL Joins Demystified: Inner, Left, Right, and Outer

If you’ve ever worked with relational databases, you know that most data doesn’t live in a single table. That’s where JOINs come in. They let you connect data across multiple tables to create a complete story.

During my undergrad, I remember learning the different joins in one of my classes and I was just like:

But in this post, I’m going to break down the four most common JOIN types in a fun and easy way. If you’re an analyst and job skills mention SQL, these are essential to your success! But before I do, I want to cover Table Aliases.

table aliases

When you’re working with joins, table names can get long and repetitive. That’s where aliases come in.

WHAT’S AN ALIAS?

An alias is just a nickname for a table that makes your query shorter and easier to read.

For example, instead of writing:

Aliases become a game-changer and you can instead write:

Here, I’ve given customers the alias c and orders the alias o.

  • c stands for Customers
  • o stands for Orders

This way, the query is cleaner and it’s easier to see which table each column comes from.

TIPS

  • CONSISTENCY IS KEY: Always use the same alias convention so others can follow your queries.
  • KEEP IT INTUITIVE: Use short, obvious letters like c for customers, o for orders, p for products.
  • IMPROVES READABILITY: Especially helpful when you join 3+ tables.

Now, let’s get into the meat of this post!

1. inner join

the matchmaker.

USE CASE: Return only the rows that exist in BOTH tables.

CODE SNIPPET:

RESULTS: Only the customers who have placed orders. Anyone without an order gets excluded.

2. left join

EVERYTHING FROM THE LEFT

USE CASE: Keep all rows from the left table, and match data from the right if it exists.

CODE SNIPPET:

RESULTS: A list of every customer — even those who haven’t placed an order yet. Missing values from the right table will show as NULL.

3. right join

EVERYTHING FROM THE RIGHT

USE CASE: The mirror of LEFT JOIN. Keep all rows from the right table, and match data from the left if possible.

CODE SNIPPET:

RESULTS: You’ll see every order in the system — even if the customer record is missing (maybe due to data entry issues).

4. full outer join

THE UNION OF BOTH

USE CASE: Return all rows from both tables, with matches.

CODE SNIPPET:

RESULTS: This shows every customer and every order, whether or not they match. It’s the widest view — useful for finding gaps in data where possible.

Visual Summary

  • INNER JOIN: Only matches
  • LEFT JOIN: Everything from the left + matches
  • RIGHT JOIN: Everything from the right + matches
  • FULL OUTER JOIN: Everything from both sides

wrapping up

I hope you enjoyed this little lesson on SQL Joins!

Remember, JOINS are the glue of SQL. Mastering them will allow you to:
✅ Combine multiple datasets into one view
✅ Identify gaps and mismatches
✅ Build richer insights for business questions

Next time you’re writing a query, think: Do I need just the matches, or everything from one side (or both)?

That answer will guide which JOIN you use.

💡 CONFESSION TIME: I didn’t fully understand JOINs until I had to write complex queries in the real world. In my next post, I’ll share how JOINs finally “clicked” for me — and why it’s normal if they still feel confusing at first.

👉 In a future post, I’ll share how JOINs came together for me — and why it’s completely normal if you don’t feel 100% confident with them yet.

Ardonna •ᴗ•

Ardonna Cardines Avatar

Categories
Analysis Analytics Business Tips

5 SQL Queries Every Analyst Should Know

SQL is one of the most important tools in any analyst’s toolkit. Whether you’re pulling transactional sales data, cleaning messy records, or preparing insights for dashboards, SQL is often the very first step.

If you’re just getting started, here are the five SQL queries that will cover 80% of your daily work as an analyst.


SELECT

The Foundation

This is your bread and butter: pulling data from a table.

Think of SELECT as your “give me the data” query. It’s the most basic — and the most powerful — command in SQL.

CODE SNIPPET:


WHERE

Filtering Results

Analysts rarely want all the data. WHERE lets you focus on what matters.

CODE SNIPPET:

For example, the query above pulls only shipped orders after January 1, 2025. Trust me, this is especially important when you’re working with millions of records that go back years. You do not want to be poring over a list that seems infinite and neither does the recipient who may have requested the ad-hoc report from you.

WHERE can be used to filter by categories or conditions as well.


GROUP BY

Summarizing Data

Aggregation is where insights begin. GROUP BY helps you summarize large datasets.

CODE SNIPPET:

Now you can see which products have the most orders. Perfect for identifying bestsellers or analyzing trends.


JOIN

Combining Tables

Most real-world data lives in multiple tables. JOIN lets you stitch it together.

CODE SNIPPET:

This connects customer details with their order history. Almost every analytics project requires joins at some point.

JOIN is often the most confusing query that beginners come across since there are different types. It can get confusing but don’t let that intimidate you, I’ll cover the different types of joins in a separate post 🙂


CASE

Adding Logic to Queries

Sometimes you need to create quick categories without exporting to Excel or Python. That’s where CASE comes in.

CODE SNIPPET:

This example creates a new column that classifies orders as “High Value” or “Standard.”

WRAPPING UP

These five SQL queries are the building blocks of data analysis. Master them, and you’ll unlock the ability to:

  • Extract exactly the data you need
  • Summarize and explore patterns
  • Connect multiple sources together
  • Add quick insights directly in SQL

Once you’re comfortable with these basics, you’ll be ready for more advanced techniques like CTEs, window functions, and query optimization.

Ardonna •ᴗ•

Ardonna Cardines Avatar

Categories
Analysis Analytics Growth Notes Thoughtful Thoughts

Why Mercury Musings?

Mercury rules Virgo, and as a Virgo, I’ve always been detail-oriented, analytical, and curious about how things connect. If you asked me ten years ago that my career would revolve around data and analytics, I wouldn’t have believed you. I was a pre-nursing major in college and that first year, I realized the medical field wasn’t for me. By sophomore year, I was lost trying to figure out a new major to switch to and I spent weeks trying to decide until I came across Information Management.

I know, soooooooooo interesting and cool right?!

Tbh, I don’t remember exactly how I discovered it but I remember part of my decision stemmed from taking a business class that all freshman students were required to take. It was an introductory course to using tools like Excel and PowerPoint. Out of all the classes I took my freshman year, that was the one I enjoyed the most.

It wasn’t until my senior year of my undergrad that I finally realized I was on the right path and doing something I enjoyed. Funnily enough, it wasn’t until a couple of years ago that I made the connection between my sun sign (Virgo) and the field I ended up in — ha ha ha. If you’re even a *little* into astrology, then you’d know that Virgo is ruled by Mercury.

Which leads me into the next part: my blog name.

the name: mercury musings

I’ve never been one for boring usernames or titles — I’ve lost count of all the moments in my academic career where I’d sit down to write an essay or report and I’d spend an absurd amount of time just trying to think of a title. If you’re a millennial who grew up watching SpongeBob, this is me just thinking of a title:

Any who, back to why I chose the name. I wanted something unique and creative that would play on both my personality and professional style:

Mercury = planet of communication, detail, and intellect

+

musings = casual reflections, notes, and insights.

Together, Mercury Musings reflects both my professional mindset and my personal curiosity: thoughtful, precise, and always seeking connections.

And if you’re a Sailor Moon fan, you can already guess which character speaks to me the most:

what you’ll find here.

Mercury Musings is a place where I’ll share:

Tips + Tutorials — breaking down concepts and techniques in data science and analytics.

Project Reflections — walking through real-world analyses, from dashboards to clustering models.

Insights — thoughts on decision-making, detail-oriented work, and the learning process.

My goal is to write in a way that’s approachable, useful, and a little personal — mixing the precision of analytics with the curiosity that Mercury inspires. And I probably won’t be able to help myself from throwing in a meme or two or many…

Fair Warning: You’ll probably even see me post about random non-data related things that I think are cool or stuff that I’m obsessed with like a new book, my favorite brand of yarn, my go-to purse, or my new favorite game •⩊•

looking ahead.

For now, this space is a blog — a place for me to write, reflect, and share. Over time, it will grow into a larger portfolio, with project showcases, teaching resources, and eventually research.

In other words, Mercury Musings is not just about where I am today, but where I’m headed. So —

welcome.

If you’re interested in analytics, detail-driven decision-making, or simply enjoy thoughtful yapping from a Virgo mind, I invite you to follow along.

Welcome to Mercury Musings.

Ardonna •ᴗ•

Ardonna Cardines Avatar