#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Step 4
4 min read

SELECT Statement

Retrieve and view data from your database tables.

What is SELECT?

SELECT retrieves data from a table. It's the most used SQL command - you'll use it every time you want to see data.

The Syntax

SELECT columns FROM table_name;

Select All Columns

Use * to get everything:

SELECT * FROM students;

Result: (see table below)

SELECT * FROM students - All Columns
idnameagegrade
1Alice20A
2Bob22B
3Charlie21A
3 rows

Select Specific Columns

Choose only what you need:

SELECT name, age FROM students;

Result: (see specific columns table below)

SELECT name, age - Specific Columns
nameage
Alice20
Bob22
Charlie21
3 rows

SELECT DISTINCT

Get unique values only (no duplicates):

SELECT DISTINCT grade FROM students;

Returns: A, B, C (each grade only once)

Column Aliases (AS)

Rename columns in your results:

SELECT name AS student_name FROM students;

How SELECT Works (Step by Step)

Step 1: Write SELECT

Step 2: List columns (or * for all)

Step 3: Write FROM

Step 4: Specify table name

Step 5: Add semicolon ;

SELECT name, age -- Step 1 & 2 FROM students; -- Step 3, 4 & 5

Quick Reference

  • SELECT * - All columns
  • SELECT col1, col2 - Specific columns
  • SELECT DISTINCT col - Unique values only
  • SELECT col AS alias - Rename column

Tip: Always select only the columns you need - it's faster than using *!

Try SELECT *

Get all columns from the students table

SQL Editor
Loading...
Output

Click "Run Query" to see results

Finished this topic?

Mark it complete to track your progress and maintain your streak!