Bird
Raised Fist0
SQLquery~10 mins

SELECT all columns in SQL - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - SELECT all columns
Start Query
↓
Parse SELECT *
↓
Identify Table
↓
Retrieve All Columns
↓
Return All Rows with All Columns
↓
End Query
The query starts by reading SELECT * which means all columns from the specified table are retrieved and returned.
Execution Sample
SQL
SELECT * FROM employees;
This query retrieves every column and every row from the employees table.
Execution Table
StepActionEvaluationResult
1Parse querySELECT * FROM employeesReady to execute
2Identify tableemployeesTable found with columns: id, name, role, salary
3Retrieve columns* means all columnsColumns selected: id, name, role, salary
4Fetch rowsAll rows from employeesRows fetched: 3
5Return resultAll columns and rowsResult set with 3 rows and 4 columns
6End queryQuery completeExecution finished
💡 All rows and all columns retrieved, query execution ends.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
tableundefinedemployeesemployeesemployeesemployees
columnsundefinedundefinedid, name, role, salaryid, name, role, salaryid, name, role, salary
rowsundefinedundefinedundefined3 rows fetched3 rows fetched
result_setundefinedundefinedundefinedundefined3 rows x 4 columns
Key Moments - 2 Insights
Why does SELECT * return all columns instead of just one?
SELECT * is a shortcut that tells the database to include every column from the table, as shown in execution_table step 3 where all columns are selected.
Does SELECT * limit the number of rows returned?
No, SELECT * returns all rows by default unless a WHERE clause is added. Execution_table step 4 shows all rows are fetched.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what columns are selected at step 3?
ANo columns selected yet
Bid, name, role, salary
COnly id and name
DOnly salary
💡 Hint
Check the 'Retrieve columns' action in execution_table step 3.
At which step does the query fetch all rows from the table?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Look for 'Fetch rows' action in execution_table.
If the table had 5 columns instead of 4, how would the result set change?
AIt would return 5 columns
BIt would still return 4 columns
CIt would return only 1 column
DIt would return no columns
💡 Hint
SELECT * means all columns, so adding columns increases the count in result_set.
Concept Snapshot
SELECT * syntax:
SELECT * FROM table_name;

- '*' means all columns
- Returns all rows by default
- Useful to quickly get full table data
- Can be combined with WHERE to filter rows
Full Transcript
This visual execution shows how the SQL query SELECT * FROM employees works step-by-step. First, the query is parsed and the employees table is identified. Then, the * symbol tells the database to select all columns from the table. Next, all rows are fetched from employees. Finally, the full result set with all columns and rows is returned. This helps beginners see how SELECT * retrieves complete data from a table.

Practice

(1/5)
1. What does the SQL query SELECT * FROM employees; do?
easy
A. It deletes all data from the employees table.
B. It creates a new employees table.
C. It updates all columns in the employees table.
D. It retrieves all columns and all rows from the employees table.

Solution

  1. Step 1: Understand the SELECT * syntax

    The asterisk (*) means select all columns from the specified table.
  2. Step 2: Apply to the employees table

    The query fetches every column and every row from the employees table.
  3. Final Answer:

    It retrieves all columns and all rows from the employees table. -> Option D
  4. Quick Check:

    SELECT * = all columns and rows [OK]
Hint: SELECT * means get everything from the table [OK]
Common Mistakes:
  • Thinking SELECT * deletes or updates data
  • Confusing SELECT * with creating tables
  • Assuming it selects only one column
2. Which of the following is the correct syntax to select all columns from a table named products?
easy
A. SELECT * FROM products;
B. SELECT products.*;
C. SELECT columns FROM products;
D. SELECT ALL FROM products;

Solution

  1. Step 1: Recall the correct SELECT syntax

    The correct way to select all columns is using SELECT * FROM table_name.
  2. Step 2: Check each option

    SELECT * FROM products; matches the correct syntax exactly.
  3. Final Answer:

    SELECT * FROM products; -> Option A
  4. Quick Check:

    SELECT * FROM table = correct syntax [OK]
Hint: Use SELECT * FROM table_name to get all columns [OK]
Common Mistakes:
  • Using SELECT ALL instead of SELECT *
  • Forgetting FROM keyword
  • Trying to select 'columns' literally
3. Given the table students with columns id, name, and age, what will the query SELECT * FROM students WHERE age > 20; return?
medium
A. All students regardless of age.
B. Only the age column for students older than 20.
C. All columns for students whose age is greater than 20.
D. An error because * cannot be used with WHERE.

Solution

  1. Step 1: Understand SELECT * with WHERE clause

    SELECT * fetches all columns, and WHERE filters rows based on condition.
  2. Step 2: Apply condition age > 20

    Only rows where age is greater than 20 are returned, with all columns shown.
  3. Final Answer:

    All columns for students whose age is greater than 20. -> Option C
  4. Quick Check:

    SELECT * + WHERE filters rows [OK]
Hint: SELECT * returns all columns; WHERE filters rows [OK]
Common Mistakes:
  • Thinking WHERE limits columns instead of rows
  • Assuming * selects only one column
  • Believing * cannot be used with WHERE
4. Identify the error in this SQL query: SELECT * employees;
medium
A. Table name should be in quotes.
B. Missing FROM keyword before table name.
C. Using * is not allowed in SELECT.
D. SELECT cannot be used without WHERE.

Solution

  1. Step 1: Check SQL SELECT syntax

    The correct syntax requires FROM before the table name.
  2. Step 2: Identify missing keyword

    The query misses FROM between SELECT * and employees.
  3. Final Answer:

    Missing FROM keyword before table name. -> Option B
  4. Quick Check:

    SELECT * FROM table is correct syntax [OK]
Hint: Always use FROM before table name in SELECT [OK]
Common Mistakes:
  • Omitting FROM keyword
  • Thinking * is invalid
  • Adding unnecessary quotes around table name
5. You want to quickly check all data in a large table named orders. Which query is best to avoid slowing down your database?
hard
A. SELECT * FROM orders LIMIT 10;
B. SELECT * FROM orders;
C. SELECT order_id FROM orders;
D. DELETE FROM orders WHERE order_id < 10;

Solution

  1. Step 1: Understand SELECT * impact on large tables

    SELECT * fetches all rows and columns, which can be slow on big tables.
  2. Step 2: Use LIMIT to reduce rows fetched

    Adding LIMIT 10 fetches only 10 rows, making the query faster and safer.
  3. Final Answer:

    SELECT * FROM orders LIMIT 10; -> Option A
  4. Quick Check:

    LIMIT reduces rows, speeding up SELECT * [OK]
Hint: Use LIMIT with SELECT * on big tables to speed queries [OK]
Common Mistakes:
  • Running SELECT * without LIMIT on large tables
  • Confusing DELETE with SELECT
  • Selecting only one column when all data is needed
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard