Your first select

Every SQL journey starts with one keyword: SELECT. It is the command that retrieves data from a table. Think of a table as a spreadsheet, and SELECT lets you pick which columns to see and from which sheet.

first_select.sql
sql
-- See everything in the customers table (first 10 rows)
SELECT * FROM customers LIMIT 10;

SELECT * means "all columns". LIMIT 10 stops after 10 rows so you do not flood your screen.

SELECT * is great for exploration, especially when you are first looking at a table and want to see what columns exist. In production queries, you should list specific columns because it makes your query self-documenting, avoids sending unnecessary data over the network, and will not break if someone adds a column later.

select_columns.sql
sql
-- Select specific columns with aliases
SELECT
  customer_city AS city,
  customer_state AS state
FROM customers
LIMIT 10;

-- AS renames the column in your results
-- The actual table column is unchanged

Listing columns explicitly is clearer and more efficient. AS creates an alias, which is a temporary rename for your results.

Now that you know how to select specific columns, let us explore a few more tables in the dataset to see what data is available.

explore_tables.sql
sql
-- Explore the orders table
SELECT * FROM orders LIMIT 5;

-- Explore products with specific columns
SELECT
  product_id,
  product_category_name,
  product_weight_g,
  product_photos_qty
FROM products
LIMIT 5;

Get comfortable exploring different tables. Each one holds a different piece of the e-commerce puzzle.

Fill in the blanks: Write your own select

Loading practice…

Quiz: Quiz

Loading practice…

Flashcards: Flashcards

Loading practice…