Skip to main content

Using the LIKE Operator and Wildcards

in List of Functions
Authors list
Published: 25. јун 2019.|Last updated: 3. нов 2022.

In DPQL  you can use the LIKE operator in the WHERE clause to check for certain patterns.

You would use it alongside wildcards:

%  represents any number of characters

_  represents one character

ExamplesCopy link to Examples to clipboard

Tickets from a single email domainCopy link to Tickets from a single email domain to clipboard

An example of this you could use would be if you wanted to look at all tickets from users under a specific email domain.

The query below wouldn't work as the email address is incomplete:

SELECT Tickets.id, tickets.person.emails.email FROM tickets WHERE tickets.person.emails.email = 'deskpro.com'
copy

However if rather than = we use Like and the % wildcard we can pull all emails that end in deskpro.com

SELECT Tickets.id, tickets.person.emails.email FROM tickets WHERE tickets.person.emails.email LIKE '%deskpro.com'
copy

Tickets from similar email domainsCopy link to Tickets from similar email domains to clipboard

Similarly if we wanted to pull all tickets submitted from Deskpro.com and Deskpro.co.uk we could use the following as the second % would bypass the characters specified after deskpro:

SELECT Tickets.id, tickets.person.emails.email FROM tickets WHERE tickets.person.emails.email LIKE '%deskpro%'
copy

Wildcard VariationsCopy link to Wildcard Variations to clipboard

You can play around with the way you use wildcards to return values in different scenarios.

Below are some wildcard variations that return support@deskpro.com :

WHERE

LIKE

Description

WHERE  person.emails.email

LIKE 'Support%'

Any values that begin with support

WHERE  person.emails.email

LIKE '%Deskpro.com'

Any values  that end with deskpro.com

WHERE  person.emails.email

LIKE '%Deskpro%'

Any values that contain Deskpro

WHERE  person.emails.email

LIKE 's%m'

Any value that starts with S and ends with M

WHERE  person.emails.email

LIKE '_u%'

Any value that has a U at the second position

HelpfulUnhelpful

0 of 1 people found this page helpful

next pageREPLACE
previous pageIN

Please log in or register to submit a comment.