SQL - Structured Query Language

LIKE (Wild Card) Operator



LIKE operator is used to find out collection of records from group of records based on specific character string matches a specified pattern. A pattern can include regular characters and wildcard characters. During pattern matching, regular characters must exactly match the characters specified in the character string. However, wildcard characters can be matched with arbitrary fragments of the character string.
List of Wildcard Character
Symbol Name Description
% Percentage Any string composed of zero or more characters.
_ Under Score Any single character.
[ ] Squire Bracket Any single character matching the specified set or range.
[^] Squire Bracket with Power Any single character not matching the specified set or range.

If it is possible, implicitly SQL Server converts character data type, while the arguments column data types are not string data type. The following queries are used to find out collection of records from PRODUCT table based on particular string pattern data values.

-- Example 49 --

 

SELECT * FROM Product WHERE Prod_Tax LIKE 15

 

SELECT * FROM Product WHERE Prod_Name LIKE 'Product A'

 

SELECT * FROM Product WHERE Prod_Name LIKE 'Product%'

 

SELECT * FROM Product WHERE Prod_Name LIKE 'Product _'


Query Output Screen

* * * * *


Email Your Comment To AUTHOR