SQL WHERE Clause

  • To limit the number of rows use the WHERE clause.
  • The WHERE clause filters for rows that meet certain criteria.
  • WHERE is followed by a condition that returns either true or false.
  • WHERE is used with SELECT, UPDATE, and DELETE.
The definitive guide
for data professionals


Order today!
 See 2 min video



The SQL WHERE syntax


A WHERE clause with a SELECT statement:
SELECT column-names
  FROM table-name
 WHERE condition

A WHERE clause with an UPDATE statement:
UPDATE table-name
   SET column-name = value
 WHERE condition

A WHERE clause with a DELETE statement:
DELETE table-name
 WHERE condition



SQL WHERE Clause Examples



Problem: List the customers in Sweden

SELECT Id, FirstName, LastName, City, Country, Phone
  FROM Customer
 WHERE Country = 'Sweden'


Results:  2 records

Id FirstName LastName City Country Phone
5 Christina Berglund Luleå Sweden 0921-12 34 65
24 Maria Larsson Bräcke Sweden 0695-34 67 21




Problem: Update the city to Sydney for supplier Pavlova, Ltd.
UPDATE Supplier
   SET City = 'Sydney'
 WHERE Name = 'Pavlova, Ltd.'


Results: 1 record updated.





Problem: Delete all products with unit price higher than $50.
DELETE FROM Product
 WHERE UnitPrice > 50


Results: 7 records deleted.

Note: Referential integrity may prevent this deletion.
A better approach may be to discontinue the product, that is, set IsDiscontinued to true.