SQL WHERE Clause

By Hemanta Sundaray on 2022-12-12

We can restrict our query results using the WHERE clause in order to obtain only the information we want.

The statement below filters the result set to only include students whose total marks is greater than 90:

SELECT *
FROM students
WHERE total_marks > 90;

How does it work?

  • The WHERE clause filters the result set to only include rows where the following condition is true.

  • total_marks > 90 is the condition. Here, only rows with a value greater than 90 in the total_marks column will be returned.

  • The > is an operator. Operators create a condition that can be evaluated as either true or false.

Comparison operators used with the WHERE clause are:

  • = equal to
  • != not equal to
  • > greater than
  • < less than
  • >= greater than or equal to
  • <= less than or equal to

Join the Newsletter