Font size
  • A-
  • A
  • A+
Site color
  • R
  • A
  • A
  • A
Skip to main content
Readepert
  • Home
  • Calendar
  • Course Categories
    Programming Languages AI, ML And Data Science
  • Exams
  • Results
  • Tutorials
  • Books
  • Colleges
  • Universities
  • Schools
  • Webstes
  • Software & Tools
  • Compilers & Practice Tools
  • More
You are currently using guest access
Log in
Readepert
Home Calendar Course Categories Collapse Expand
Programming Languages AI, ML And Data Science
Exams Results Tutorials Books Colleges Universities Schools Webstes Software & Tools Compilers & Practice Tools
Expand all Collapse all

SELECT Statement Basics

  1. Dashboard
  2. Courses
  3. Programming Languages
  4. SQL
  5. Module 2: SQL Basics – Data Retrieval
  6. SELECT Statement Basics
Completion requirements

1. 🔹 What is SELECT?

  • The SELECT statement is used to retrieve data from a database table.

  • It is the most common SQL command and forms the foundation of querying.

👉 General Syntax:

 
SELECT column1, column2, ... FROM table_name;
  • SELECT → specifies which columns to show.

  • FROM → tells SQL which table to get data from.


2. 🔹 Selecting All Columns

If you want to get all the data from a table, use * (wildcard).

 
SELECT * FROM Employees;

👉 Example Table: Employees

EmployeeID Name Department Salary
101 John HR 50000
102 Alice IT 70000
103 David Finance 65000

📌 Result:
Shows all rows and columns of the Employees table.


3. 🔹 Selecting Specific Columns

You can choose only the columns you want.

 
SELECT Name, Salary FROM Employees;

📌 Result:

Name Salary
John 50000
Alice 70000
David 65000

4. 🔹 Using WHERE Clause (Filtering Data)

The WHERE clause filters rows based on conditions.

 
SELECT Name, Department FROM Employees WHERE Salary > 60000;

📌 Result:

Name Department
Alice IT
David Finance

5. 🔹 Using Aliases (Renaming Columns)

Aliases help make results more readable.

 
SELECT Name AS EmployeeName, Salary AS MonthlySalary FROM Employees;

📌 Result:

EmployeeName MonthlySalary
John 50000
Alice 70000
David 65000

6. 🔹 Removing Duplicate Results (DISTINCT)

The DISTINCT keyword removes duplicates.

 
SELECT DISTINCT Department FROM Employees;

📌 Result:

Department
HR
IT
Finance

7. 🔹 Sorting Results (ORDER BY)

You can sort rows in ascending (ASC) or descending (DESC) order.

 
SELECT Name, Salary FROM Employees ORDER BY Salary DESC;

📌 Result:

Name Salary
Alice 70000
David 65000
John 50000

8. 🔹 Limiting Results (LIMIT / TOP)

  • In MySQL & PostgreSQL → LIMIT

  • In SQL Server → TOP

 
-- MySQL / PostgreSQL SELECT * FROM Employees LIMIT 2; -- SQL Server SELECT TOP 2 * FROM Employees;

📌 Result:
Shows only the first 2 rows.


9. 📊 Summary

Keyword Purpose Example
SELECT * All columns SELECT * FROM Employees;
SELECT col1, col2 Specific columns SELECT Name, Salary FROM Employees;
WHERE Filter rows WHERE Salary > 60000;
AS Rename column Name AS EmployeeName
DISTINCT Remove duplicates SELECT DISTINCT Department;
ORDER BY Sort results ORDER BY Salary DESC;
LIMIT / TOP Restrict rows LIMIT 5 / TOP 5

✅ You now know how to:

  • Select all or specific columns

  • Filter results

  • Rename columns

  • Remove duplicates

  • Sort and limit results

This lesson is not ready to be taken.
Previous activity 4. 🔹 SQLite Installation
Next activity Filtering Data with WHERE Clause

Contact us

Follow us

You are currently using guest access (Log in)
Data retention summary
Get the mobile app
Get the mobile app
Play Store App Store
Powered by Moodle

This theme was proudly developed by

Readexpert.com