Your first practical SQL skill is reading data intentionally. SELECT defines the columns or expressions in the result, and FROM identifies the table supplying the rows. You will build a query from a simple request, understand aliases, and learn why results need explicit ordering when order matters.
Key Takeaways at a Glance:
- •SELECT specifies column projection (which attributes to return); FROM specifies the data source relation.
- •SQL executes FROM first to identify the source table, then processes SELECT to construct the output tuple.
- •Column aliases (AS) create readable display headers but are NOT accessible in the WHERE clause of the same query block.
- •DISTINCT filters duplicate rows across the entire combination of selected projection columns.
In Simple Words (The Mental Model)
Think of a spreadsheet with 50 columns and 10,000 rows. When answering a question like 'What are the names and cities of our customers?', you don't need all 50 columns. SELECT allows you to pull only the 2 columns you care about, cutting network bandwidth and memory usage.
Real-World Analogy
Think of an eye doctor test. The eye chart on the wall has 10 lines with 80 letters (the table). The doctor holds up a mask with two cut-out holes showing only the letters 'A' and 'B' (the SELECT projection). The other 78 letters still exist on the wall, but you only see the two framed by the mask.