Friday, September 17, 2010

SQL WHERE Clause

The WHERE clause is used to extract only those records that fulfill a specified criterion.

SQL WHERE Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name operator value





WHERE Clause Example

The "Persons" table:



Now we want to select only the persons living in the city "Mumbai" from the table above.

We use the following SELECT statement:

SELECT * FROM Persons
WHERE City='Mumbai'


NOTE : SQL uses single quotes around text values (most database systems will also accept double quotes).

Although, numeric values should not be enclosed in quotes.


This is correct:

SELECT * FROM Persons WHERE Year=1990

This is wrong:

SELECT * FROM Persons WHERE Year='1990'

0 comments:

Post a Comment