From the course: Querying Microsoft SQL Server 2019

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Match text with LIKE and wildcards

Match text with LIKE and wildcards - SQL Server Tutorial

From the course: Querying Microsoft SQL Server 2019

Start my 1-month free trial

Match text with LIKE and wildcards

- [Instructor] When filtering the results of a query based off of text values, you can use the equalsTo comparison operator to find text that exactly matches your criteria. But when you need to find approximate text that matches a pattern, you'll need to use the LIKE operator. Let's start this example by getting a list of people names from the database with the query SELECT FirstName from Person.Person. This'll just pull out the single FirstName column from a table in the Person schema named Person. I'll execute the query and I'll see that I have over 19,000 individual names that we can work with. Now, if I wanted to get just the names that started with the letter A, you can add a WHERE clause that reads this. WHER FirstName is LIKE and then in single quotes the pattern you want to match. In this case, A% and then we'll close the single quote. The LIKE operator and the percent symbol create a text pattern and the…

Contents