SQL NOT OperatorThe NOT is a logical operator in Structured Query Language. This Operator in SQL negates the output of any boolean expression. This operator compares the given value to each value and returns those values which do not satisfy the condition. NOT Operator operator is mainly used in WHERE clause with the INSERT, UPDATE, DELETE and UPDATE SQL statements. Syntax of NOT Operator in Structured Query Language:In the SQL syntax, we have to specify the NOT keyword in the WHERE clause with the condition. Example of NOT Operator in SQLTo understand the query of NOT Operator in Structured query Language, we have to create the new table called Worker_Info. This table contains the details of workers working in the industry. The following query creates the Worker_Info table in the Industry Database: The following INSERT queries insert the records of multiple workers who work in the Industry: The following query shows the data of the Worker_Info table.
The following query shows the records of those workers from the above table who does not belong to Kolkata City:
The following query does not show the records of those workers from the above table whose Salary is greater than 30000. Output:
NOT Operator with IN operator in SQLWe can also use the NOT operator with IN operator in SQL for filtering those records which do not pass in the parenthesis of IN operator. Syntax of NOT Operator with IN operator Example of NOT Operator with IN operator The following query shows those records of workers whose Worker_ID is not passed in the IN operator: Output:
NOT Operator with the LIKE operator in SQLWe can also use the NOT operator with the LIKE operator in SQL for filtering those values which do not match with the specified pattern. Syntax of NOT Operator with LIKE operator Examples of NOT Operator with LIKE operator Example 1: The following query shows those records of workers from the worker_Info table whose First Name does not start with A. Output:
Example 2: The following query does not show those records of workers from the worker_Info table whose City name begins with D character and ends with i character. Output:
Next TopicINSTR Function in SQL |