# Logical Operators In SQL [ AND, OR, NOT ]

This SQL SELECT Statement tutorial will focus more on using logical conditions. The Logical conditions combines the result of two component conditions to produce single result based on them or inverts the results of a single condition.

Take note: It will only returned a row when the overall result of the condition is true.

## Three Logical Conditions are:

Logical operators in SQL AND, OR, and NOT

1. AND

Meaning It will return TRUE if both conditions are TRUE

2. OR

it will Return TRUE if either of the statements or conditions return true

3. NOT

It will return TRUE if the following condition is FALSE.

## Sample Table

Sample table used in this Logical operators in SQL. tblsampleemployee

## Using AND Operator

Take Note: When using AND operator, it requires both condition to be true.

Sample Query:

```SELECT `EMPNAME`, `SALARY`
FROM `tblsampleemployee`
WHERE `EMPNAME` = 'Kobe Bryant'
AND `SALARY`=50000 ```

Output:

Explanation:

In the example, both conditions must be true for any record to be selected. Therefore only employee named “Kobe Bryant” that match in our conditions. Which the employee name is Kobe Bryant and Salary of 50000.

Take note: All characters are case sensitive. it means it will not returned row if ‘EMPNAME’ is “kobe bryant”. The K and B should be in uppercase.

## Using the OR Operator

Take Note: When using OR operator, it requires either condition to be true.

Sample Query:

```SELECT `EMPNAME`, `SALARY`
FROM `tblsampleemployee`
WHERE `EMPNAME` = 'Kobe Bryant'
OR `SALARY`> 50000```

Output:

Explanation:

In the example, either conditions can be true for any record to be selected. Therefore only employee named “Kobe Bryant” and those employee has a salary greater than 50000 is selected.

## Using the OR Operator

Sample Query:

```SELECT `EMPNAME`,`SALARY`,`DEPT_NAME`
FROM `tblsampleemployee`
WHERE `DEPT_NAME` NOT IN ('IT','SALES') ```

Output:

Explanation:

In the example above displays the Employee name, Salary, and Department Name whose department is not IT and Sales.

## Video demonstration below

Watch the Video here: