Wildcards(“_” and “%”) in SQL
Posted: January 17th, 2008 | Author: Nischal Shetty | Filed under: SQL | 2 Comments »We can use the WILDCARDS “_” and “%” in our SQL queries be it MS SQL or My SQl as follows:
Wildcard underscore “_” :
“_” helps to match exactly one character.
Ex. select name from name_table where name like “c_p”
The above query will return words such as “cap”, “cop”, “cup” or basically anything which is a three letter word starting with the letter “c” and ending with “p”.
Wildcard “%” :
“%” helps match any number of characters. Let’s take the same example as above:
select name from name_table where name like “c%p”
The output can be “cap”, “cop” and can also be “coooop”, “caawjshygfvsbchjsp” etc etc.
So what basically happens with “%” is that it will include any number of characters whereas “_” will include only one character.












THANK ALOT! Was studying for my upcoming test and had no idea what my textbook is talking about.
hey anytime buddy.. If there’s any more information you need I’ll be more than happy to help you
All the best for your exams ;o)