Skip to content

SELECT & WHERE

Pick the columns you want and drop the rows you do not

0 of 3 done · Lesson 1 of 8

Understand

The sales table holds every order the company has taken, and someone has asked you for the Auckland ones. Scrolling through it and picking by eye is where mistakes come from. A query says three things instead: which columns you want, which table they live in, and which rows are worth keeping.

SELECT which_columns_you_want
FROM where_it_lives
WHERE which_rows_to_keep;
SELECTwhich columns you wantFROMwhich tableWHEREwhich rows to keep

The tables you are working with

8 rows
First rows of the orders table
idcustomercitystatusamount
1041NorthwindAucklandpaid420
1042Kea LtdWellingtonpaid180
1043HalcyonAucklandpending950
1044BrightsmithChristchurchpaid500

4 more rows in the table. Your query sees all 8.