Course contentsShow
← Data Science
Lesson 854 of 2,14522. SQL FoundationsFree lesson

Writing Your First Complete Query

Combine SELECT and FROM to write complete SQL queries that retrieve specific data from a database table.

Writing Your First Complete Query

You'll learn how to put together SELECT and FROM into a working SQL query that actually retrieves data from a database table.

The Complete Picture

You've learned the two essential pieces—SELECT tells the database what columns you want, and FROM tells it where to find them. Now it's time to combine them into your first fully functional SQL query.

Think of it like ordering at a restaurant: you need to say both what you want ("I'll have the salmon") and where it comes from ("from the dinner menu"). In SQL, you're doing the same thing with data.

The Basic Structure

Every complete query follows this pattern:

SELECT column_name
FROM table_name;

Notice the semicolon at the end—it signals "this query is complete."

Real Examples

Here's a complete query to get all customer names:

SELECT customer_name
FROM customers;

Want multiple columns? List them with commas:

SELECT customer_name, email, city
FROM customers;

Need everything? Use the asterisk you learned:

SELECT *
FROM orders;

What Happens When You Run It

When you execute this query, the database engine:

  1. Locates the specified table (FROM)
  2. Retrieves the requested columns (SELECT)
  3. Returns all rows that match

The result is a new temporary table showing just the data you asked for.

Key Takeaway: A complete SQL query requires both SELECT (what columns) and FROM (which table), ending with a semicolon—this combination is the foundation of all data retrieval in SQL.