🔥 $100K Hit! Where Will Bitcoin Go Next? Find Out Live!

Code has been added to clipboard!

SQL WHERE – the Filtering Clause and Its Operators

Reading time 1 min
Published Jan 6, 2016
Updated Oct 3, 2019

SQL WHERE: Main Tips

  • The WHERE clause is applied to sort just those records that correspond the condition.
  • It is applied in SELECT, UPDATE, DELETE statements.

SQL WHERE Syntax

Example
SELECT column1, column2, ...
FROM table_name
WHERE condition;
DataCamp
Pros
  • Easy to use with a learn-by-doing approach
  • Offers quality content
  • Gamified in-browser coding experience
  • The price matches the quality
  • Suitable for learners ranging from beginner to advanced
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable
Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid Certificates of completion
edX
Pros
  • A wide range of learning programs
  • University-level courses
  • Easy to navigate
  • Verified certificates
  • Free learning track available
Main Features
  • University-level courses
  • Suitable for enterprises
  • Verified certificates of completion

WHERE Clause Operators

Operator Description
= Equal
<> or != Not equal
> Greater than
< Less than
>= Equal or greater than
<= Equal or Less than
BETWEEN Between a certain range
LIKE Search for a specific pattern
IN To define multiple possible column values

Demo Database

This is a demo database used for examples of this post:

ID Name City Country
1 Tom Kurkutis New York USA
2 Ana Fernandez London UK
3 Antonio Indigo Paris France
4 Aarav Kaelin Delhi India
5 Andrew Tumota Miami USA
6 Basma Zlata Miami USA

Examples for Using SQL WHERE

The following example selects all the developers from the country 'France' in the Developers table:

Example
SELECT * FROM Developers
WHERE Country='France';

This example shows that numeric fields do not require quotes:

Example
SELECT * FROM Developers
WHERE ID=1;