In SQL, AND operator is used to compare data with more than one condition, and it will return records only when all the defined conditions are TRUE
.
Generally, we will use AND operator in the WHERE
clause, and syntax for AND
operator in SQL will be like as following statements.
Following is the syntax of defining an AND operator in SQL statements.
We will check this with the example for that first create “EmployeeDetails” table by using the following script in the SQL database.
When we run the above SQL script, the “EmployeeDetails” table will create, and the result is like below.
Now run the following examples to check AND
operator in the SQL server.
In the following SQL query, we check multiple conditions (Location, Salary) with AND operator. It will return records that satisfy both conditions.
When we execute the above SQL query, we will get the result below.
In the following SQL query, we check Location and Empname conditions with AND
operator. It will return records that satisfy the defined conditions.
When we execute the above SQL query, we will get the result below.