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

Master SQL in hands-on training