Friday, January 8, 2010

SQL Where

Next, we might want to conditionally select the data from a table. For example, we may want to only 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"

store_name Sales Date
Los Angeles $1500 Jan-05-1999
San Diego $250 Jan-07-1999
Los Angeles $300 Jan-08-1999
Boston $700 Jan-08-1999

we key in,

SELECT store_name
FROM Store_Information
WHERE Sales > 1000

Result:
store_name
Los Angeles

For More Details: http://www.1keydata.com/sql/sqlwhere.html

No comments:

Post a Comment