In SQL, Operators are special character, symbol or a keyword that is used to perform some specific operations. For example : comparing data
SQL operators are commonly used with SQL statements to retrieve, filter, and manipulate data.
NOT LIKE operator act as a search engine that searches for the specified pattern or substring in a column and returns rows where a specified pattern does not match. It is used in 'WHERE' clause to filter and retrieve specific data. Pattern refers to a sequence of characters in SQL. It can be a single or multiple character.
SELECT column_name(s) FROM table_name WHERE column NOT LIKE pattern;
• Specify the column(s) name after the 'SELECT' keyword.
• Specify Asterisk (*) symbol to selects all columns from the table after the 'SELECT' keyword.
• Specify the table name after the 'FROM' keyword.
• Specify the conditions after the 'WHERE' keyword.
• Specify the pattern after the 'NOT LIKE' keyword.
1. Let's assume we have a table named "[Employees]".
Let's assume you want to retrieve employee data from [Employees] table where Employee_Name doesn't start with character 'A'.
Run below SQL statement :
SELECT * FROM [Employees] WHERE Employee_Name NOT LIKE 'A%';
Above statement will retrieve employee data where Employee_Name doesn't start with character 'A'.
Let's assume you want to retrieve employee data from [Employees] table where Employee_Name doesn't end with character 'Y'.
Run below SQL statement :
SELECT * FROM [Employees] WHERE Employee_Name NOT LIKE '%Y';
Above statement will retrieve employee data where Employee_Name doesn't end with character 'Y'.
Let's assume you want to retrieve employee data from [Employees] table where Employee_Name doesn't has character 'E' anywhere.
Run below SQL statement :
SELECT * FROM [Employees] WHERE Employee_Name NOT LIKE '%E%';
Above statement will retrieve employee data where Employee_Name doesn't has character 'E' anywhere.
The "NOT LIKE" operator in SQL query is used to filter records that do not match a specified pattern.
Yes, "NOT" can be used with "LIKE" in SQL to negate the pattern matching.
The "NOT" operator in SQL is used to negate a condition or expression.
No, there isn't a "NOT IN" operator in SQL; however, you can use the "NOT" operator with the "IN" operator to achieve similar functionality.