In a query, the LIKE operator allows the user to query for a character or group of characters anywhere within a text field. It does this by matching the field to a string which mixes the character(s) you want to match with wildcard characters like * and ?. Some examples:
- FirstName LIKE "C*" will return any name that starts with a C (i.e. Carlton, Clark)
- LastName LIKE "*-*" will return any last name that has a hyphen anywhere in the field (i.e. Flickema-Carlson, Smith-Jones)
- PONum LIKE "C????" will return and PO number that starts with a C and has exactly 5 characters. (i.e. CSIDF, C24DG)
- PONum LIKE "C##" returns all values that start with a C, is exactly 3 characters long, and characters 2 and 3 MUST be numbers. (i.e. C45, C16)
So how can I search for a wildcard character itself? I can simply enclose the wildcard character with brackets .
For instance, if I wanted to find any value that has an asterisk (*) anywhere in it, I could do this:
- PO LIKE "*[*]*"
If I wanted to find any value that starts with a hash mark(#), I could do this:
- Check LIKE "[#]*"
If I wanted to find any value ending with a question mark (?), I could do this:
- Comment LIKE "*[?]"