Lesson 5
Beginner Level
5 of 30 lessons
SELECT Statement
Learn how to use SELECT to retrieve data from database tables. The SELECT statement is the most fundamental SQL command for querying data.
What is SELECT?
The SELECT statement is used to query and retrieve data from one or more tables in a database. It’s the most commonly used SQL command and forms the foundation of data retrieval.
Syntax
SELECT column1, column2, ...
FROM table_name;
To fetch all columns from a table, you can use the asterisk (*) symbol:
SELECT * FROM employees;
Example
SELECT first_name, last_name
FROM employees;
This will return the first and last names of all employees in the employees table.
Practice Task
- Write a query to select all columns from the
departmentstable. - Write a query to retrieve only
job_idandsalaryfrom theemployeestable. - What does
SELECT * FROM dual;return?