TutorialsSQLSELECT Statement
🟢 Free Demo
SQL TutorialTopic 2 of 20

SELECT Statement

Fetch data from a database table

✅ What You Will Learn

How to use SELECT to fetch specific columns from a table
The difference between SELECT * and naming columns
How to create calculated columns using arithmetic
How to rename columns with AS (aliases)
How SELECT DISTINCT removes duplicate values
Why you should avoid SELECT * in production queries

The SELECT statement is the most used command in SQL. Every query that retrieves data starts with SELECT. You use it to choose which columns to display from a table.

When you write a SELECT query, you are telling the database: "Give me these specific columns from this specific table." The database returns a result set — a temporary table of matching rows that only exists while you are viewing it.

SELECT does not change or delete any data. It only reads. This makes it completely safe to run on any database.

📋 The orders table used in examples

order_idcustomer_nameproductamountcityorder_date
1001Rahul SharmaLaptop45000Delhi2026-01-15
1002Priya VermaMobile Phone18000Noida2026-01-16
1003Amit KumarHeadphones3500Gurgaon2026-01-16
1004Sneha KapoorLaptop52000Delhi2026-01-17
1005Vikram SinghTablet28000Noida2026-01-18

Syntax

SQL SYNTAX
SELECT column1, column2, ...
FROM table_name;

-- To select all columns:
SELECT *
FROM table_name;

Examples

Example 1Select specific columns
SELECT customer_name, product, amount
FROM orders;
OUTPUT
customer_name | product      | amount
--------------|--------------|-------
Rahul Sharma  | Laptop       | 45000
Priya Verma   | Mobile Phone | 18000
Amit Kumar    | Headphones   | 3500
Sneha Kapoor  | Laptop       | 52000
💡

Only the three requested columns are returned — order_id and order_date are excluded.

Example 2Select all columns using *
SELECT *
FROM orders;
💡

The asterisk (*) is a shorthand for "all columns". Useful for exploration but avoid it in production queries — always name the columns you actually need.

Example 3Add a calculated column
SELECT customer_name,
       amount,
       amount * 0.18 AS gst_amount,
       amount + (amount * 0.18) AS total_with_gst
FROM orders;
OUTPUT
customer_name | amount | gst_amount | total_with_gst
--------------|--------|------------|---------------
Rahul Sharma  | 45000  | 8100.00    | 53100.00
Priya Verma   | 18000  | 3240.00    | 21240.00
💡

AS gives the calculated column a readable name. This is called an alias.

Example 4SELECT DISTINCT — remove duplicates
SELECT DISTINCT product
FROM orders;
OUTPUT
product
---------
Laptop
Mobile Phone
Headphones
💡

DISTINCT returns only unique values. Laptop appeared twice in the table but appears once in the result.

📌 Key Points to Remember

  • SELECT fetches data — it never modifies the original table
  • List column names separated by commas after SELECT
  • Use * to get all columns (for exploration only)
  • AS creates an alias — a temporary name for a column in the result
  • SELECT DISTINCT removes duplicate rows from the result

🏢 Real-World Application

Every dashboard you see at a company is powered by SELECT queries. A sales report in Power BI pulls data using SELECT customer_name, SUM(revenue) from a sales table. A finance team member checking daily transactions runs SELECT * FROM transactions WHERE date = TODAY(). When a product manager asks "how many users signed up this week?", a data analyst writes a SELECT query with COUNT() to answer it instantly. SELECT is the foundation of every SQL query you will ever write — mastering it means you can start answering business questions immediately.

⚠️ Common Mistakes to Avoid

WRONGUsing SELECT * in every query
FIXAlways name the specific columns you need. SELECT * returns all columns, wastes bandwidth on large tables, and breaks downstream code if the table structure changes.
WRONGForgetting commas between column names
FIXEach column in a SELECT list must be separated by a comma. Missing a comma causes a syntax error: SELECT customer_name product is invalid; SELECT customer_name, product is correct.
WRONGWriting the alias without AS
FIXSome databases allow SELECT amount gst but it is confusing. Always write AS explicitly: SELECT amount * 0.18 AS gst_amount for clarity and compatibility.
✏️Test Yourself

Which SQL statement is used to fetch data from a database?

❓ Frequently Asked Questions

What does SELECT * do in SQL?

SELECT * retrieves all columns from a table. It is useful for quick exploration but should be avoided in production queries because it fetches unnecessary data, slows performance on large tables, and can break code if columns are added or removed.

Can you use SELECT without FROM?

Yes — in many databases you can run SELECT 1+1 or SELECT GETDATE() without a FROM clause to calculate expressions or get system values. But for table data, FROM is always required.

What is the difference between SELECT and SELECT DISTINCT?

SELECT returns all rows, including duplicates. SELECT DISTINCT removes duplicate rows and returns only unique combinations of values for the selected columns.

How do you rename a column in SQL SELECT?

Use the AS keyword: SELECT amount * 0.18 AS gst_amount. The alias only exists in the result set — it does not change the actual column name in the database table.

Is SELECT case-sensitive in SQL?

The SELECT keyword itself is not case-sensitive — SELECT, select, and Select all work. But string data comparisons (like WHERE city = 'Delhi') may be case-sensitive depending on the database and its collation settings.

✏️ Practice Exercise

Write a query to select only the customer_name and order_date from the orders table.

← PreviousSQL IntroductionNext →WHERE Clause
🎓 Level Up Faster

Learn SQL with Live Trainer Guidance

These tutorials give you the theory. Our live SQL course at EVIKA Academy, Noida teaches you to apply SQL on real company datasets — with a trainer who uses it daily at MakeMyTrip.