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.