What is FROM?
FROM tells SQL which table to get data from. Like telling a librarian "get me books FROM the fiction section."
How FROM Works
Step-by-step:
- SELECT name, age - What columns you want
- FROM students - Which table to look in
- Get data - Database finds the table and columns
- Return - Results come back to you
Basic Syntax
SELECT columns FROM table_name;Examples
-- Get all columns from students
SELECT * FROM students;
-- Get specific columns
SELECT name, age FROM students;
-- With WHERE filter
SELECT name FROM students WHERE age > 20;Query Order
SELECT columns -- 1. What to show
FROM table_name -- 2. Where to get it
WHERE condition -- 3. Filter results
ORDER BY column; -- 4. Sort resultsTable Aliases (Shortcuts)
Give tables shorter names:
-- Long way
SELECT students.name FROM students;
-- Short way with alias
SELECT s.name FROM students s;Try FROM Below
Use the playground to practice FROM queries.
What Comes Next
Next: Learn WHERE clause to filter your results.
Try SELECT...FROM
Query data from the table. Try: SELECT name, age FROM students;
Source Table: students
| id | name | age | grade |
|---|---|---|---|
| 1 | Alice | 20 | A |
| 2 | Bob | 22 | B |
| 3 | Charlie | 21 | A |
| 4 | David | 23 | B |
4 rows
SQL Editor
Loading...