Loading
SELECT Command
The SELECT command is one of the most fundamental and frequently used commands in SQL.
It is used to retrieve data from a database table.

In simple terms, whenever you want to view or read data stored in a table, you use the SELECT command.

Important: The SELECT command does not modify the data. It only displays the requested information.


Understanding Database and Table

Before learning SELECT, it is important to understand two basic terms:

  • Database: A structured place where data is stored.
  • Table: A collection of data organized in rows and columns.

Think of a table as a spreadsheet:

  • Columns represent fields (such as name, age, marks).
  • Rows represent individual records.


Example: Students Table

idnamemarks
1Rahul85
2Anjali90


Why Use the SELECT Command?

The SELECT command is used to:

  • Retrieve data from a table
  • Display specific or all columns
  • Generate reports
  • Analyze stored information
  • Safe to use
  • Read-only operation
  • Does not change database data

Syntax

SELECT column_name
FROM table_name;

  • SELECT specifies what data to retrieve
  • FROM specifies which table contains the data


Selecting All Columns from a Table

To retrieve all columns from a table, use the asterisk (*) symbol.

SELECT * FROM students;


Output

idnamemarks
1Rahul85
2Anjali90
The * symbol means all columns.


Selecting Specific Columns

To retrieve data from specific columns only, mention the column names separated by commas.


Example

SELECT name FROM students;


Output


name
Rahul
Anjali



Selecting Multiple Columns

SELECT name, marks FROM students;


Output


namemarks
Rahul85
Anjali90


Important Points to Remember

  • SQL keywords are typically written in uppercase (recommended practice)
  • Column and table names must match the database exactly
  • The SELECT command only retrieves data
  • Using SELECT * is convenient for learning but not recommended for large databases


Two Minute Drill

  • SELECT is used to retrieve data from a table
  • It does not modify or delete data
  • SELECT* retrieves all columns
  • Specific columns can be retrieved by listing their names
  • FROM specifies the source table
  • Tables store data in rows and columns