A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

SQL: SELECT Statement and Basic Queries

College Depth 70 in the knowledge graph ☐ I know this ☆ Set as goal
55topics build on this
329prerequisites beneath it
See this on the map →
The Relational Data ModelRelational Algebra→→CASE WHEN: Conditional Expressions in SQLCOALESCE and NULLIF: NULL Handling Functions+11 more
SQL SELECT query retrieval

Core Idea

The SELECT statement is the primary SQL command for retrieving data from one or more tables. It specifies which columns to retrieve (projection) and which rows satisfy conditions (selection). SELECT statements form the basis of all data queries and reporting.

Explainer

If you have studied the relational data model, you know that a database organizes data into tables — rows of records, each with named columns. The SELECT statement is how you ask a relational database to give you back some or all of that data. Every SQL query you will ever write starts here.

The minimal form of a SELECT is: `SELECT column1, column2 FROM table_name;`. The keyword SELECT is followed by a comma-separated list of column names you want to retrieve — this is *projection*, restricting the result to only the columns you care about. If you want every column, you can write `SELECT *`, but this is generally avoided in production code because it returns more data than needed and breaks if columns are added or reordered later. After FROM, you name the table to query. The semicolon ends the statement.

Think of the columns after SELECT as deciding *what shape* your result has (which attributes), and the rest of the query as deciding *which rows* to include. A query like `SELECT name, salary FROM employees` will return one row per employee — just those two columns — in an unspecified order. The database does not sort rows or filter them unless you add ORDER BY or WHERE clauses (topics you will study next).

One detail that surprises many beginners: SQL is declarative, not procedural. You describe *what data you want*, not *how to find it*. The database engine decides the physical execution plan — whether to scan the whole table, use an index, or fetch pages in parallel. This is what makes SQL so powerful: you express the intent, and the engine optimizes the execution.

A crucial point from the relational model: the result of a SELECT is itself a table — a new set of rows and columns produced by the query. This is called a *derived relation*, and it means you can use query results as inputs to other queries (subqueries), or reason about them with the same relational algebra tools you used to understand tables in the first place.

Practice Questions 3 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Set Operations: Union, Intersection, and Complement → Relational Algebra → SQL: SELECT Statement and Basic Queries

Longest path: 71 steps · 329 total prerequisite topics

Prerequisites (2)

Leads To (13)