Loading, please wait...

AND & OR Operator

How To Use AND And OR Conjunctive Operators In SQL

Introduction:
In this article, you will learn what does AND and OR conjunctive operators mean and how to use these operators.

Both AND or OR operators does the work on various conditions to limit the data. Generally, we can use these operators to perform many conditions in the same SQL statement. These operators are also known as conjunctive operators.

 

The AND Operator

When we use AND Operator in our SQL statement, it provides the presence of various conditions with the WHERE clause. And operator shows the data if both conditions are true.

 

Syntax

The basic syntax of AND operator with WHERE clause is as follows:

select column1, column2,..... from table_name where [condition1] AND [condition2]...AND [condition....];

 

 

Example

 

Step 1: We write our query and combine the conditions.

 

 

 

Now select our query and execute this.

 

 

Step 2: Then the output of our query is-

 

 

 

 

The Or Operator

With the help of this operator, we worked to combine many terms in our SQL statement WHERE clause. The OR operator shows the data if either any one condition is true.

 

 

Syntax

The basic syntax of OR operator with WHERE clause is as follows:

select column1, column2,.... from table_name where [condition1] Or [condition2]...OR [condition...];

 

 

Example

 

Step 1: We write our query and Combine the conditions.

 

 

 

Now, select our query and execute this.

 

 

Step 2: The output of our query is:

 

 

 

Summary:
Thus, we learned AND and OR operator, doing the work on conditions in SQL.