In this section, we will see on the NOT operator function for.
The NOT Operator is used to reserve the Boolean value of particular expression.
The NOT operator is ordinarily used to exclude the data with certain conditon from the results display.
The SQL syntax for the NOT operator is:
SELECT [COLUMN NAME] FROM [TABLE NAME]
WHERE NOT [CONDITION]
In detailed syntax, the SQL syntax can be like this
SELECT [COLUMN NAME] FROM [TABLE NAME]
WHERE NOT [COLUMN] = [VALUE]
EXAMPLE :
We would like to exclude IT department from the data displaying.
Table GameScores
PlayerName | Department | Scores |
Jason | IT | 3000 |
Irene | IT | 1500 |
Jane | Marketing | 1000 |
David | Marketing | 2500 |
Paul | HR | 2000 |
James | HR | 2000 |
SQL statement :
SELECT * FROM GameScores
WHERE NOT Department = 'IT'
Result:
PlayerName | Department | Scores |
Jane | Marketing | 1000 |
David | Marketing | 2500 |
Paul | HR | 2000 |
James | HR | 2000 |