From the course: Querying Microsoft SQL Server 2022
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
Match text with LIKE and wildcards - SQL Server Tutorial
From the course: Querying Microsoft SQL Server 2022
Match text with LIKE and wildcards
- [Instructor] When filtering the results of a query based on text values, you can use the equals to comparison operator to find text that exactly matches your criteria. But when you need to find approximate text matches that match a pattern, you'll need to use the like operator. Let's take a look at people names from the database, with a new query that selects the first name column from the Person.Person table. Executing the query shows me over 19,000 first names that are stored in the database. Now if I just wanted to get the list of names that start with the letter A, you can add a where clause that reads where the first name... is like, and in single quotation marks, A percent. The like operator and the percent symbol create a text pattern, and the query returns just the records of all the names that start with a letter A. The percent symbol is called a wildcard, and it acts as a placeholder for any other characters. So…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Limit results with TOP4m 39s
-
(Locked)
Remove duplicates with DISTINCT2m 53s
-
(Locked)
Comparison operators3m 43s
-
(Locked)
Understand NULL values4m 42s
-
(Locked)
Match text with LIKE and wildcards4m 36s
-
(Locked)
Challenge: Retrieve matching text strings49s
-
(Locked)
Solution: Retrieve matching text strings4m 52s
-
(Locked)
Solution: Filter results from a query result4m 28s
-
-
-
-
-
-
-
-
-