Say “Hello” to the Table
Explore the fundamentals of writing your first SQL query to retrieve data from a table. Learn how to use SELECT * to view all columns and rows, understand the concept of tables as structured data, and gain confidence interacting directly with database tables.
We'll cover the following...
Welcome to SQL. In this first lesson, you’ll write a simple query to interact with a table and retrieve data, no setup or background required. Let’s get started with your first real query.
Goal
You’ll aim to:
Run your first SQL query.
View a whole table using
SELECT *.Understand the idea of a table as structured data.
Meet the table
Let’s start with a table called people that stores basic information about different individuals, like their name, age, and city. Here’s what it looks like:
The people table
ID | Name | Age | City |
1 | Aisha | 30 | Karachi |
2 | Dan | 24 | New York |
3 | Fatima | 27 | Lahore |
4 | Lee | 22 | Seoul |
Say hello with SELECT *
You’re asking SQL to show everything from the people table: every column, every row.
Congratulations! You just pulled an entire table using one line of code!
📝 Did you know?
This query works just fine without the semicolon at the end; it’s optional in many environments when running a single statement. And it also works even if you write it in lowercase. That’s because SQL is case-insensitive, soselect,SELECT, or evenSeLeCtall mean the same thing.
Quick bits
SELECT: Ask for columns.*: Wildcard for all columns.FROM: The table you’re asking.