SQL Where Clause

Friday, October 28, 2011

tags SQL

The WHERE clause is used to filter records, generally in combination with the SELECT statement. The WHERE clause is used to request only those records that fulfill a specified query.


SQL WHERE Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name operator value

WHERE Clause Example

SELECT * FROM Customers
WHERE LastName='Smith'

SELECT * FROM Customers
WHERE CustID=5

SQL uses single quotes around text values; some versions will allow double quotes.  Numeric values should not be enclosed in quotes. Operators Allowed in the WHERE Clause are as follows:


  • = Equal
  • <> Not 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
  • IN = If you know the exact value you want to return for at least one of the columns

Did you find the page informational and useful? Share it using one of your favorite social sites.

Recommended Books & Training Resources

Head First SQL: Your Brain on SQL A Learners Guide SQL Cookbook