Logical operators in SQL Server Explained

Introduction 
 
In this blog, I will explain SQL operators. SQL operators are used as arithmetic, logical and bitwise operators.
 
SQL Operators - Logical Operators
   
SQL logical operators are used to check some condition and return a boolean value. The following SQL operators are commonly used. (AND, OR, LIKE, BETWEEN, IN, NOT IN)
 
 
 
AND:
AND operator is applied between two expressions to filter records based on more than one condition. AND operator's conditions are true is return true otherwise it returns false.
Syntax:
  1. SELECT *FROM TB_NAME WHERE FIRST_NAME='MAGESH' AND LAST_NAME='R'  
OR:
The OR operators are used to filter records based on more than one condition and display a record if any of the conditions separated by OR is TRUE.
Syntax:
  1. SELECT *FROM TB_NAME WHERE ID=1 OR ID=2 OR ID=3  
LIKE:
This operator s used in a WHERE clause to search for a specified pattern in a column.
Syntax:
  1. SELECT *FROM TB_NAME WHERE FIRST_NAME LIKE 'M%'  
BETWEEN:
The BETWEEN operator selects values within a range such as (numbers, text, date), this operator also works with the AND operator.
Syntax:
  1. SELECT *FROM TB_NAME WHERE DOB BETWEEN '2018-08-03' AND '2019-08-03'  
IN:
This operator allows you to specify multiple values in a WHERE clause.
Syntax:
  1. SELECT *FROM TB_NAME WHERE ID IN (1,2,3)  
NOT IN:
The “NOT IN” operator used in displays a record within a condition. 
Syntax:
  1. SELECT *FROM TB_NAME WHERE ID NOT IN (1,2,3)