SQL SELECT Statement Basics




🔍 Introduction

The SQL SELECT statement is the foundation of SQL. It’s used to retrieve data from one or more tables. Almost every query you’ll write starts with SELECT.

If you’re following our SQL series, you should already know how to insert, update, and delete records. Now let’s learn how to fetch and view data.

1️⃣ Basic SELECT Query

Retrieve all columns from a table:

SELECT * 
FROM Employees;

This returns every column and row from the Employees table.

Tip: Avoid using * in production queries – it’s better to specify column names for performance and clarity.

2️⃣ Selecting Specific Columns

You can select only the columns you need:

SELECT FirstName, LastName, Salary 
FROM Employees;

3️⃣ Using Aliases (AS)

Aliases make your results easier to read by giving temporary names to columns or tables.

SELECT FirstName AS "Employee First Name", 
       Salary AS "Annual Salary"
FROM Employees;

4️⃣ Filtering Results with WHERE

Use WHERE to return only specific rows.

SELECT FirstName, Salary 
FROM Employees
WHERE Salary > 60000;

5️⃣ Sorting Results with ORDER BY

The ORDER BY clause arranges results in ascending (ASC) or descending (DESC) order.

SELECT FirstName, Salary 
FROM Employees
ORDER BY Salary DESC;

✅ Key Takeaways

  • SELECT * → Retrieves all columns
  • Specify column names for better performance
  • AS → Use aliases for readability
  • WHERE → Filter rows
  • ORDER BY → Sort results

📚 Continue Learning

💬 Got a question about SQL SELECT basics? Drop it in the comments below and let’s discuss!




Leave a Comment