SQL Basics | DML: Data Manipulation Language | WHERE

The WHERE clause is used to filter records. It extracts only records that satisfy the specified condition.

You do not always load all data from a table. Often, you load data selectively. For example, if you need to retrieve only data with sales of $1,000 or more, use the WHERE clause.

WHERE syntax

The WHERE clause is as follows.

SELECT column_name1, column_name2, ...
FROM table_name
WHERE condition;

WHERE example

Suppose you need to retrieve data with sales of $1,000 or more from the following table.

store_information table

store_name sales txn_date
Los Angeles 1500 Jan-05-2018
San Diego 250 Jan-07-2018
Los Angeles 300 Jan-08-2018
Boston 700 Jan-08-2018

Enter the following command.

SELECT Store_Name
FROM Store_Information
WHERE Sales > 1000;

The result is as follows.

Store_Name
Los Angeles