Skip
Arish's avatar

5. Practice - SELECT All


Exercise: SELECT All Data

Practice retrieving all data from tables.

Task 1: Get All Students

Write a query to retrieve all records from the students table.

Solution

sql
1SELECT * FROM students;

Task 2: Get All Courses

Write a query to retrieve all records from the courses table.

Solution

sql
1SELECT * FROM courses;

Task 3: Get All Teachers

Write a query to retrieve all records from the teachers table.

Solution

sql
1SELECT * FROM teachers;

Understanding the Output

When you run SELECT *:

  1. All columns are returned
  2. All rows are returned
  3. Order matches table storage (unless specified)

Common Mistakes

sql
1-- Missing FROM clause
2SELECT * students;  -- Error!
3
4-- Missing table name
5SELECT * FROM;  -- Error!
6
7-- Typo in table name
8SELECT * FROM studnets;  -- Error!

Key Takeaways

  • SELECT * retrieves all columns
  • Always specify the table with FROM
  • Table names are case-sensitive in some databases
  • End queries with semicolon