SQL Where Clause

With SQL WHERE clause we can specify the condition to filter the rows from the result. There are two types of conditions:

  1. Simple Conditions
  2. Compound Conditions
  • Simple Conditions:

Simple conditions contains the one of the SQL operators as given in the below table.

Operator Description
< Less than
<= Less than or equal to
> Greater than or equal to
= Equal to
<>,!= Not equal to

Below example shows the usage of WHERE clause with simple condition. Suppose user require all the customers information which are male. Below query makes use of WHERE clause to get the all the customers which are male.

SQL> desc customers
 Name                                      Null?    Type
 ----------------------------------------- -------- ---------------------
 CUSTOMER_ID                                        NUMBER
 AGE                                                NUMBER
 GENDER                                             CHAR(1)


We can use the other operators as per our conditions to filter the rows.

  • Compound Conditions:

Compound condition consist of multiple sub-conditions which are combined with logical operators AND,OR and NOT. Click Here to read more about these operators.

Leave a Reply