What is SELECT?
SELECT is the most fundamental SQL command. It allows you to retrieve data from one or more tables in your database.
Think of it like asking a question to your database: "Show me this information from that table." Every data retrieval operation in SQL starts with SELECT.
Basic Syntax
SELECT column1, column2, ...
FROM table_name;💡 Pro Tip: SQL keywords like SELECT and FROM are not case-sensitive, but it's common practice to write them in UPPERCASE for readability.
Common Patterns
Use * to retrieve all columns from a table
SELECT * FROM customers;Result: Returns all columns: id, name, email, country, etc.
See It In Action
Watch how SELECT retrieves and transforms data step by step.
Select Specific Columns
Choose only the columns you need
Input Data
idINTEGER | nameTEXT | emailTEXT | countryTEXT | ageINTEGER |
|---|---|---|---|---|
| 1 | Alice Johnson | [email protected] | USA | 28 |
| 2 | Bob Smith | [email protected] | Canada | 35 |
| 3 | Carlos Silva | [email protected] | Brazil | 22 |
| 4 | Diana Chen | [email protected] | USA | 41 |
| 5 | Emma Davis | [email protected] | Canada | 19 |
SQL Query
SELECT name, country
FROM customersResult
5 rowsnameTEXT | countryTEXT |
|---|---|
| Alice Johnson | USA |
| Bob Smith | Canada |
| Carlos Silva | Brazil |
| Diana Chen | USA |
| Emma Davis | Canada |
Key Concepts
The Asterisk (*)
Using * selects ALL columns. Great for exploration, but specify columns in production for better performance.
Column Aliases
Use AS to rename columns in your output. Makes results more readable and meaningful.
Multiple Columns
Separate column names with commas to select multiple specific columns. Order matters - columns appear in the order you list them.
Semicolon
End your SQL statements with a semicolon ;It's required in most databases and is considered best practice.
Common Mistakes to Avoid
❌ Missing FROM clause
SELECT name, email;You must specify which table to select from!
❌ Missing commas between columns
SELECT name email FROM customers;Always separate column names with commas!
✅ Correct syntax
SELECT name, email FROM customers;Perfect! All elements in place.