Tuesday, August 18, 2015

NOT operator in SQL Server

Introduction to NOT operator:
Mostly we will use this keyword with LIKE and IN operators which will revese the action does by them.

If you want to select the data whose EmployeeID is not in 1, 3, 5 then just add NOT before IN clause:
SELECT
       *
FROM
       dbo.Employee
WHERE
       EmployeeID NOT IN (1, 3, 5)



In the same way if you don't want to see the employees whose name is starting with A then add NOT before LIKE operator:
SELECT
       *
FROM
       dbo.Employee
WHERE
       EmployeeName NOT LIKE 'A%'



Labels: , , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home