Skip to main content
/1 min read

SQL WHERE Tutorial

How WHERE Works

Filters Rows

Sets a condition that data records must meet to be returned.

Syntax

SELECT * FROM table WHERE condition

Common Use

Finding players with more than 10 points — SELECT * FROM stats WHERE points > 10;

Combine with AND/OR

WHERE points > 10 AND team = 'A' filters on multiple criteria.

Master SQL at Noble Desktop

Noble Desktop's SQL Bootcamp covers queries, joins, aggregations, and the full SQL toolkit data analysts use every day.

This tutorial walks through the basics of the WHERE statement in SQL and an example of how to use it.

WHERE Statement

  • The WHERE statement is used to filter data from our table.

  • It sets a condition to be met for data records to be retrieved.

  • Syntax: SELECT * FROM table WHERE condition

Example

Let’s say we have a basketball league and we keep records of each player, which team they are on, and their basic statistics.

Stats Table

If we wanted to use a SQL query to find all the players with more than 10 points, we would write the following:

SQL WHERE statement

Once we hit ENTER and run, our result should be as follows:

SQL WHERE Result