Your First SELECT Statements

Your First SELECT Statements

Here’s the thing about SQL: once you understand SELECT, you’ve unlocked the door to every database in the world. This single command is how you ask a database “show me what you’ve got” - and trust me, databases have a lot to show you.

What SELECT Actually Does

Think of SELECT like pointing at something and saying “I want that.” You’re not changing anything, you’re not breaking anything - you’re just looking. It’s the safest command in SQL, which makes it perfect for beginners.

When you run a SELECT statement, you get back what’s called a result set. This is just a fancy term for “the answer to your question, displayed as a table.” The database takes your request, finds the data you asked for, and hands it back to you in neat rows and columns.

Basic SELECT Syntax

Every SELECT statement follows the same basic pattern:

1SELECT [what you want]
2FROM [which table];

That’s it. Two keywords, and you’re talking to a database. Let’s see this in action.

Your First Query: SELECT *

The asterisk (*) is SQL’s way of saying “everything.” It’s like walking into a room and saying “show me what’s in here.”

1SELECT *
2FROM employees;

This query says: “Show me everything from the employees table.” The database will return every column and every row from that table. It’s the nuclear option - you get it all.

Here’s what you might see back:

| id | first_name | last_name | department | salary |
|----|------------|-----------|------------|--------|
| 1  | Sarah      | Johnson   | Marketing  | 65000  |
| 2  | Mike       | Chen      | IT         | 72000  |
| 3  | Lisa       | Williams  | Sales      | 58000  |

Selecting Specific Columns

But here’s the thing - you don’t always want everything. Most of the time, you want specific information. That’s where column names come in:

1SELECT first_name, last_name
2FROM employees;

Now you get just the names:

| first_name | last_name |
|------------|-----------|
| Sarah      | Johnson   |
| Mike       | Chen      |
| Lisa       | Williams  |

You can select as many or as few columns as you want. Just separate them with commas:

1SELECT first_name, department, salary
2FROM employees;

The Column Order Matters

Here’s something that trips up beginners: the order you list columns is the order they appear in your result. If you write:

1SELECT salary, first_name, department
2FROM employees;

You’ll get salary first, then name, then department. The database doesn’t care about the original table order - it gives you exactly what you asked for, in the order you asked for it.

Understanding Result Sets

Every time you run a SELECT, you get a result set. Think of it as a temporary table that exists just long enough to show you the answer. A few key things to know:

It’s not the actual table - You’re looking at a copy of the data, formatted for your query. The original table stays exactly the same.

It might be empty - If your query doesn’t match any data, you get back a result set with zero rows. That’s not an error, that’s just “sorry, no matches.”

It’s always a table shape - Even if you select just one column from one row, it still comes back as a table with one column and one row.

SELECT * vs. Specific Columns: When to Use Each

Use SELECT * when:

  • You’re exploring a new table and want to see what’s there
  • You’re doing quick checks during development
  • You genuinely need all the columns

Use specific columns when:

  • You know exactly what data you need
  • You’re writing queries that other people will use
  • Performance matters (and it usually does)

Here’s why specific columns are usually better: imagine a table with 50 columns and a million rows. SELECT * asks the database to gather and send you 50 million pieces of data. If you only need 3 columns, that’s a lot of wasted work.

Real-World Example

Let’s say you’re building a simple employee directory. You don’t need salary information or hire dates - just names and departments:

1SELECT first_name, last_name, department
2FROM employees;

This gives you exactly what you need, nothing more. It’s faster, cleaner, and easier to work with.

Common Beginner Mistakes

Forgetting the semicolon - SQL statements end with semicolons. Some databases are forgiving, but get in the habit now.

Mixing up table and column names - If you get an error like “column doesn’t exist,” double-check your spelling and make sure you’re using the right table name.

SELECT without FROM - You can’t select from nothing. Every SELECT needs a FROM clause (with one exception in some databases, but ignore that for now).

Try This Yourself

If you have access to a practice database, try these queries:

  1. SELECT * FROM [any table]; - See everything
  2. SELECT [one column] FROM [same table]; - Focus on one piece of data
  3. SELECT [column1], [column2] FROM [same table]; - Get specific information

What’s Next

You’ve just learned the foundation of SQL. Every complex query you’ll ever write starts with SELECT and FROM. Next, we’ll learn how to filter this data with WHERE clauses - because getting everything is nice, but getting exactly what you want is powerful.

The beautiful thing about SELECT is that it’s completely safe. You can’t break anything, you can’t delete data, you can’t mess up a table. So experiment, play around, and get comfortable asking databases questions. They’re surprisingly good at answering.