...

/

Hello, Data! Meet SQL

Hello, Data! Meet SQL

Learn the fundamentals of SQL to efficiently query and filter data stored in relational databases.

Beyond files and APIs, data is often stored in relational databases, which are systems designed for efficient, structured storage and retrieval. Relational databases store data in tables, just like a spreadsheet, with rows and columns. But unlike a single file, databases can connect multiple tables together, enforce data consistency, and handle huge volumes of records efficiently.

To interact with and fetch data from these databases, we use structured query language (SQL), the primary tool for interacting with relational databases. At its core, SQL lets us select the information we need, specify where it comes from, and narrow down results to exactly what’s relevant.

SQL is how we talk to relational databases. It’s how we ask for the data we want, filter the noise, and shape results into meaningful answers. Whether we’re analyzing employee salaries, tracking customer orders, or prepping data for building a visualization, SQL is a tool we’ll reach for again and again.

Fun fact: The first version of SQL was developed at IBM in the 1970s. It originally stood for “Structured English Query Language” (SEQUEL), which is why some people still pronounce it “sequel” today!

In this lesson, we’ll explore the fundamental building blocks of SQL queries—how to select data, apply filters, and return only what’s relevant.

Sample data: Employees table

To understand how SQL works, let’s start with a simple example table called employees. It stores information about employees in a company, including their ID, name, department, hire date, and salary.

EmployeeID

Name

Department

HireDate

Salary

1

Alice Johnson

Engineering

2020-03-15

85,000.00

2

Bob Smith

Marketing

2019-07-22

65,000.00

3

Carol Martinez

Sales

2021-01-08

72,000.00

4

David Liu

Engineering

2018-11-02

95,000.00

5

Eva Gómez

HR

2022-05-16

58,000.00

6

Frank O’Connor

Finance

2017-09-30

78,000.00

7

Grace Patel

Engineering

2023-02-12

80,000.00

8

Hiro Tanaka

Support

2020-12-01

60,000.00

9

Isabella Rossi

Marketing

2021-06-25

67,000.00

10

Arya Stark

Sales

2019-04-10

71,000.00

This table will help us explore the core building blocks of SQL.

Selecting data: The SELECT and FROM clauses

When we start querying a database, two SQL clauses are essential: SELECT and FROM. They work hand in hand to tell the database what data we want and where to find it.

Fun fact: SQL is case-insensitive, but people often write keywords in UPPERCASE to make queries easier to read.

SELECT is how we specify the exact columns, or ...