SELECT Statement

The SELECT statement retrieves data from one or more tables - it is the most frequently used SQL command and the foundation of virtually every data query.

Basic Syntax

SELECT column1, column2
FROM table_name
WHERE condition
ORDER BY column1;

Common Examples

-- Select all columns
SELECT * FROM customers;

-- Select specific columns
SELECT first_name, city FROM customers;

-- Filter rows
SELECT * FROM customers WHERE city = 'Noida';

-- Sort results
SELECT * FROM customers ORDER BY signup_date DESC;

-- Limit the number of rows
SELECT * FROM customers LIMIT 10;

Useful Clauses

  • WHERE - filters rows based on a condition
  • ORDER BY - sorts the result set
  • GROUP BY - groups rows for aggregate calculations like COUNT or SUM
  • JOIN - combines rows from two or more related tables
SELECT is read-only and never modifies data, which makes it safe to experiment with while exploring a new database.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course