Sunday, 26 January 2020

LIKE operator in SQL Server

Hi All,

Hope you all are doing good.

In this article, I will explain you about how to use LIKE operator in different scenarios.

If we want to perform search based on pattern matching then we will use LIKE operator.

Patterns with examples

PatternDescriptionExample
%any string of zero or more characters.SELECT last_name FROM Customers WHERE last_name LIKE 'su%'
_any single character.SELECT last_name FROM Customers WHERE last_name LIKE '_u%'
[list of characters]any single character within the specified set.SELECT last_name FROM Customers WHERE last_name LIKE '[YZ]%'
[start_character-end_character]any single character within the specified range.SELECT last_name FROM Customers WHERE last_name LIKE '[A-C]%'
[^]any single character not within a list or a range.SELECT last_name FROM Customers WHERE last_name LIKE '[^C-Z]%'

Thanks for reading my article.

No comments:

Post a Comment

Intoduction to Flutter

Hi All, I hope every one is doing good In this article, we will know about the introduction of Flutter.