Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Returning all data from a table
Select some columns
Filtering rows
Logic
Text patterns
16. The percentage wildcard (%)
To be or NULL to be
A bit of mathematics
Let's practice

Instruction

Great! Now, what happens if we don't know precisely what string we're looking for, but we have a rough idea? With text values, you can always use the LIKE operator instead of the equality operator. What does this change? Well, take a look at the following example:

SELECT
  *
FROM User
WHERE Name LIKE N'A%';

LIKE allows for the use of the percentage wildcard (%). The percentage wildcard (%) applied in the example replaces any number (zero or more) of unknown characters.

As a result, we'll obtain all users whose name begins with the letter 'A'. We may not remember someone's exact name, but we know it begins with an 'A' and that's enough for our purposes. Convenient, right?

Exercise

Select the Vin, Brand, and Model of all cars whose brand begins with an 'F'.

Stuck? Here's a hint!

Type:

SELECT
  Vin,
  Brand,
  Model
FROM Car
WHERE Brand LIKE N'F%';