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 AlgebraCASE 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 ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesSet Operations: Union, Intersection, and ComplementRelational AlgebraSQL: SELECT Statement and Basic Queries

Longest path: 71 steps · 329 total prerequisite topics

Prerequisites (2)

Leads To (13)