Back to course

The SELECT Statement: Basic Retrieval

Database Fundamentals: From Zero to Hero

Lesson 14: The SELECT Statement: Basic Retrieval

The SELECT statement is the core of SQL. It is used to query data from the database. It is often the first command a database professional learns.

Basic Syntax

sql SELECT [column_list] FROM [table_name];

1. Retrieving All Columns

If you want to retrieve every column in a table, use the asterisk (*).

sql -- Retrieve all data from the Employees table SELECT * FROM Employees;

2. Retrieving Specific Columns

If you only need certain information, specify the column names separated by commas. This is generally preferred in production environments as it saves resources.

sql -- Retrieve only the name and salary of employees SELECT Name, Salary FROM Employees;

3. Using Semicolons

Always end your SQL statements with a semicolon (;). This tells the database engine where one command ends and the next begins. While some systems are lenient, it is required for proper practice.