To conditionally select the data from a table the WHERE clause is used .
eg.if we want to retrieve stores with sales above $1,000. To do this, we use the WHERE keyword. The syntax is as follows:
SELECT "column_name"
FROM "table_name"
WHERE "condition"
For example, to select all stores with sales above $1,000 in Table Store_Information.
store_name
Sales
Date
Los Angeles
$1500
Jan-05-2005
San Diego
$250
Jan-07-2005
Los Angeles
$300
Jan-08-2005
Boston
$700
Jan-08-2005
SQL command
SELECT store_name
FROM Store_Information
WHERE Sales > 1000
Notes: SQL uses single quotes around string values (most database systems will also accept double quotes). Numeric values not be enclosed in quotes.
Output
store_name
Los Angeles
The following operators can be used with where clause:
Operator
Description
=
Equal
<>
Not equal
>
Greater than
<
Less than
>=
Greater than or equal
<=
Less than or equal
BETWEEN
Between an inclusive range
LIKE
Search for a pattern
Note:In some versions of SQL the <> operator is equivalent to != operator
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.