All the course material is stored in the SQL Crash Course repository.
Hi everyone! Once again, Cornellius and Josep Ferrer from DataBites here👋.
I am sure you are here to continue our SQL Crash Course Journey!📚
If this is your first time or you’ve forgotten what we’ll cover, we will examine seven key SQL topics, each divided into multiple posts across Non-Brand Data and DataBites.
This post is focused on the second topic, so if you missed it, you should check out the first topic in the series.
📌 #1 What is SQL?
📌 #2 Why learn SQL?
will also post about the 📌 #3 Relational Data & Models, so don’t miss it!💪In the second topic, we will learn together about SQL Fundamentals, which consists of:
📌Basic commands
📌Filtering and Sorting
📌Aggregation Function
To begin the second topic, this post will explore the basics of SQL commands!
Without further ado, let’s get into our second course!🎉
SQL Basic📝
In the previous post, we have already understand what and why we are using SQL.
The core of SQL is how we talk with the database using the query structure, although how do we start the conversation?
🔥The answer lies in three simple SQL commands:
SELECT, FROM, and WHERE.
This course will guide you in focusing on SQL’s essentials. You’ll learn how to:
SELECT the data you want to see,
FROM the table where it’s stored,
WHERE you filter out the data to focus on what matters.
Ready to understand the basic commands? Let’s begin.
✅SELECT Basic Command
The SELECT command is the foundation of every SQL query.
It basically answers the question: “What data do I want to see?”.
What It Does
Specifies the columns to retrieve from a table.
Can perform calculations, rename columns, or aggregate data.
The Syntax is present as follows:
SELECT column1, column2
FROM table_name;
Let’s see various examples for the SELECT command:
👉Select Specific Columns
SELECT product_name, price
FROM products;
👉Select All Columns
SELECT *
FROM products;
👉Select with Calculation and Alias Name
SELECT product_name, price * 0.8 AS discounted_price
FROM products;
The Syntax for SELECT is always in the beginning, as this command signifies that we want to select something.
✅FROM Basic Command
The FROM command is where we answered: “Where is the data stored?”
What It Does
Specifies the table to query.
Can reference multiple tables (using JOIN, but that’s for later).
You have already seen the example of the FROM command in the previous Syntax; however, it will resemble the query below.
SELECT column1
FROM schema_name.table_name;
Remember always to pair SELECT with FROM, as omitting FROM will cause errors.
Additionally, use fully qualified names (e.g., sales, orders) if the tables are not in the schema where you are working right now.
✅WHERE Basic Command
The WHERE command answers: “How do I narrow down results?”
What It Does
Filters rows based on conditions.
Works with comparison operators (=, <>, >, <) and logical operators (AND, OR, NOT).
The basic Syntax when you are using the WHERE command is as follows:
SELECT column1
FROM table_name
WHERE condition;
Let’s see various examples for the WHERE command:
👉Single Filter with Comparison Operator
SELECT product_name, price
FROM products
WHERE price < 300;
👉Multiple Filter Condition
SELECT product_name
FROM products
WHERE category = 'Electronics'
AND price > 200;
👉Text Filter Condition
SELECT product_name
FROM products
WHERE product_name LIKE '%Wireless%';
👉Date Filter Condition
SELECT order_id
FROM orders
WHERE order_date >= '2023-01-01';
👉Grouped Condition
SELECT product_name
FROM products
WHERE (category = 'Electronics' OR category = 'Appliances')
AND price < 500;
That’s all the explanation you need to know for the basic SQL commands (SELECT, FROM, WHERE).
We just got started, so keep following our course until the end!
How to Get Started 🚀
Over the coming weeks, we’ll guide you through:
✅ SQL Fundamentals
✅ Intermediate SQL
✅ Advanced SQL
✅ Database Operations
✅ Writing Efficient Queries
What’s Next?➡️
This is the first of many posts about the upcoming SQL Courses. It will only explain what SQL is in its crude form.
To get the full experience and fully immersed in the learning:
👉Subscribe to Databites.tech (By Josep)
👉Subscribe to Non-Brand Data (By Cornellius)
👉Check out the SQL Crash Course GitHub repo
👉Share with your friend and whoever needs it!
🗓️ Every Thursday, you will have two new issues in your inbox!
Let’s dive in and make SQL less scary, more fun, and way more useful! 🚀
Josep & Cornellius