Skip
Arish's avatar

4. SELECT All Data


The SELECT Statement

The SELECT statement is the most fundamental SQL command. It retrieves data from database tables.

SELECT * Syntax

The asterisk * means "all columns":

sql
1SELECT * FROM table_name;

Example: Get All Students

sql
1SELECT * FROM students;

Result

idnameagecoursemarksgrade
1Alice14Python85A
2Bob12JavaScript78B
3Carol15Python92A
4David13Ruby65C

Breaking Down the Query

  • SELECT - Command to retrieve data
  • * - All columns
  • FROM - Specifies the source
  • students - Table name

When to Use SELECT *

Good for:

  • Quick data exploration
  • Small tables
  • Testing queries

Avoid when:

  • Large tables (performance)
  • Production code (specify columns)
  • Joining tables (column confusion)

Best Practice

In production, specify columns explicitly:

sql
1-- Better for production
2SELECT name, age, course FROM students;

This makes queries faster and more maintainable.