SQL Basics: SELECT
SQL (Structured Query Language) is the language you use to talk to a database. It has been the standard for over 40 years and is used by every major database system. The most fundamental operation is SELECT — retrieving data.
Key Concepts
SELECT and FROM
SELECT tells the database which columns you want. FROM tells it which table. SELECT * FROM students returns every column of every row. SELECT name, grade FROM students returns just those two columns.
WHERE — Filtering Rows
WHERE adds conditions. SELECT * FROM students WHERE grade=10 returns only 10th-grade students. You can use =, !=, <, >, <=, >=, LIKE (pattern match), and IN (list of values).
ORDER BY and LIMIT
ORDER BY sorts results. ORDER BY grade DESC puts highest grades first. LIMIT 10 returns only the first 10 rows — useful for large tables. These clauses can be combined: ORDER BY score DESC LIMIT 5 gives the top 5 scores.
🆕 SQL Query Simulator
Run SQL queries against a sample students table. Try the examples!
✅ Check Your Understanding
1. What does SELECT * FROM students return?
2. What does WHERE do in a SQL query?
3. What does ORDER BY grade DESC LIMIT 5 do?