General Note: Here we have pulled in the data from a sample database. You can download it from the following link and use it for practicing Click Here For Sample Database

LIKE operator is widely used operator for character pattern matching. Here % fills remaining all character. If you want to know brand name which starts with S, but you are unaware of remaining letters


Select brand_name from mobile_sales_Details where brand_name like S%

brand_name
----------
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Sony      
Sony      
Sony      
Sony      
Sony      

If you want to know brand name, whose name ends with S, but you are unaware of starting letters


Select brand_name from mobile_sales_Details where brand_name like %S

brand_name
----------
Asus      
Asus      
Asus      
Asus   

If you want to know brand name, whose name has the letter S at any place, but you are unaware of the starting and ending letters


Select brand_name from mobile_sales_Details where brand_name like %S%

brand_name
----------
Asus      
Asus      
Asus      
Asus      
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   


% - fills all remaining characters _ - placeholder for one character. It fills one character at one placeholder. Say for example you know the second letter of brand (a), but you do not know the starting letter and the remaining characters, to find solution for this we can use underscore(_) for first letter, then place the letter a at second position, then use % for remaining characters which you are not aware.

The query looks like


Select brand_name from mobile_sales_Details where brand_name like _a%
brand_name
----------
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Samsung   
Karbonn   
Karbonn