Saturday, January 26, 2019

Using Wildcards on SQL Statements and Formula

Wildcards must be used with the LIKE operator.

Wildcard characters and its description:

"%" is a substitute for zero or more characters
"_" is a substitute for a single character

Wildcard '%' percent example:

SELECT * FROM vendors
WHERE companyname LIKE '%XYZ%';

- In this SQL LIKE condition example, we are looking for all vendors whose company name contains the characters 'XYZ'.

Wildcard '_' underscore example:

CASE WHEN ({firstname} LIKE 'K_te') THEN 'Match' ELSE 'Not Match' END

- This matches all firstname field that has 'K' for the first letter and 'te' for the last two letters.
- For example, it returns matches whose first name is Kate, Kite, Kyte, Kete, Kute, etc.



No comments:

Post a Comment