Did you find this useful?
Socialize it today.

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.


SELECT column_name(s)
FROM table_name
WHERE column_name operator value

WHERE Clause Example

SELECT * FROM Customers
WHERE LastName='Smith'

SELECT * FROM Customers

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

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.

Recommended Books & Training Resources

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