What are SQL Keywords?
Keywords are command words that tell the database what to do. Like telling a robot: "SHOW me data" or "FIND students".
The 6 Must-Know Keywords
1. SELECT - What to show
SELECT * -- Show everything
SELECT name -- Show only name
SELECT name, age -- Show name and age2. FROM - Where to look
SELECT * FROM students; -- Look in students table
SELECT * FROM contacts; -- Look in contacts table3. WHERE - Filter results
SELECT * FROM students WHERE age > 20; -- Only age above 20
SELECT * FROM students WHERE grade = 'A'; -- Only grade A4. ORDER BY - Sort results
SELECT * FROM students ORDER BY age; -- Youngest first
SELECT * FROM students ORDER BY age DESC; -- Oldest first5. LIMIT - How many to show
SELECT * FROM students LIMIT 3; -- Show only first 36. AND / OR - Combine filters
SELECT * FROM students WHERE age > 20 AND grade = 'A'; -- Both must be true
SELECT * FROM students WHERE grade = 'A' OR grade = 'B'; -- Either can be truePutting It All Together
SELECT name, age
FROM students
WHERE grade = 'A'
ORDER BY age DESC
LIMIT 3;This says: Show name and age, from students table, only grade A, oldest first, just 3 results.
Quick Reference
- SELECT - What columns to show
- FROM - Which table to look in
- WHERE - Filter with conditions
- ORDER BY - Sort results
- LIMIT - How many rows to show
- AND/OR - Combine multiple conditions
Comparison Symbols
=equals,>greater than,<less than>=greater or equal,<=less or equal,!=not equal
Remember: Text needs quotes ('John'), numbers don't (20).
Practice: Filter with WHERE
This shows students older than 20. Try changing 20 to 19!
SQL Editor
Loading...
Output
Click "Run Query" to see results
Practice: Sort and Limit
Shows 3 oldest students. Try changing DESC to ASC!
SQL Editor
Loading...
Output
Click "Run Query" to see results