SQL: Using where clause like, underscore, escape operators
SQL Wildcard & Special Operator : Exercise-12 with Solution
Write a SQL statement to find those rows from the table testtable which contain the escape character underscore ( _ ) in its column 'col1'.
Sample Solution :
SELECT * FROM testtable WHERE col1 LIKE '%/_%' ESCAPE '/';
Output of the Query:
col1 A001/DJ-402\44_/100/2015 A001_\DJ-402\44_/100/2015 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%100 A001/DJ_402%45\2015/300
Pictorial presentation :
Contribute your code and comments through Disqus.
Previous: Write a SQL statement to find those salesmen with all information whose name containing the 1st character is 'N' and the 4th character is 'l' and rests may be any character.
Next: Write a SQL statement to find those rows from the table testtable which does not contain the character underscore ( _ ) in its column 'col1'.
What is the difficulty level of this exercise?