w3resource
SQL exercises

SQL: Using not like operator and escape characters

SQL Wildcard & Special Operator : Exercise-17 with Solution

Write a SQL statement to find those rows from the table testtable which does not contain the string ( _/ ) in its column 'col1'. 

Sample table: testtable


Sample Solution:

SELECT *
FROM testtable
WHERE col1 NOT LIKE '%/_//%' ESCAPE '/';

Output of the Query:

col1
A001_DJ-402-2014-2015
A002_DJ-401-2014-2015
A001/DJ_401
A001/DJ_402\44
A001/DJ_402\44\2015
A001/DJ-402%45\2015/200
A001/DJ_402\45\2015%100
A001/DJ_402%45\2015/300
A001/DJ-402\44

Explanation:

Syntax of using not like operator and escape characters

Pictorial presentation :

Exercise: Using not like operator and escape characters

Query Visualization:

Duration:

Query visualization of Using not like operator and escape characters - Duration

Rows:

Query visualization of Using not like operator and escape characters - Rows

Cost:

Query visualization of Using not like operator and escape characters - Cost

 

Practice Online


Contribute your code and comments through Disqus.

Previous: Write a SQL statement to find those rows from the table testtable which contain the string ( _/ ) in its column 'col1'.
Next: Write a SQL statement to find those rows from the table testtable which contain the character ( % ) in its column 'col1'.

What is the difficulty level of this exercise?