Friday, July 29, 2016

SQL Wildcards Characters



In SQL wildcards characters are used with LIKE operator. It is used to search data from table.
The wildcards characters are given below:

                     Wildcard
                   Description
%
Substitute for Zero or more characters
_
Substitute for a single characters
[charlist]
Used to find the range of characters to match
[^charlist] or [!charlist]
Match only character NOT specified within brackets

Example -
Firstly we create the table emp




SQL % wildcard

select * from emp where name like 's%'

output –



SQL _ wildcard

select * from emp where name like '_achin'

output – 

SQL [charlist] wildcard


select * from emp where name like '[sp]%'
 output – 




SQL [^charlist] wildcard

select * from emp where name like '[^sp]%'
or
select * from emp where name NOT LIKE '[sp]%'



output – 
                                                              Author - Sachin pathak