GCGrowCarrer

Loops and Iteration

Locked

Lesson 5 of 25 · Syntax · Easy

Finish these first:Conditionals and Branching →Or pass the tests below to unlock it now.

1

The big idea

In other languages, you write a for loop to step through items one by one. In SQL, the database loops through every row in a table automatically!

Think of it like this: Think of SQL like telling a helper 'count every folder in this drawer' — instead of writing a manual loop, the database walks through every row for you.
Key words (tap to learn):
2

Read the lesson

In other languages, you write a for loop to step through items one by one. In SQL, the database loops through every row in a table automatically!

For example, COUNT(*) visits every row in a table and tells you how many rows there are:

SELECT COUNT(*) FROM students;

You already have a sample table called employees ready in memory — use SELECT COUNT(*) FROM employees; to count all of its rows in one line.

3

Quick check

What does `SELECT COUNT(*) FROM employees;` calculate?

4

Your challenge

1 sample test, 1 hidden

Count how many people are in the employees table (type SELECT COUNT(*) FROM employees;).

Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)

Compare with another language

Similar to python.loops (90% overlap). Iteration: for-of in JS, range-for in C++, single 'for' keyword in Go, Iterator/for-in in Rust.

Visual walkthrough

A diagram, a step-by-step animation, and short captions for Loops and Iteration.

Mastery0%