Using Wild Card Characters

The Like operator compares values to a pattern that usually includes wild card characters.  These characters are placeholders, either for 1 character or for an unknown number of characters.

Use the character:

Matches in an expression:

? or _ (underscore) Any single character
* or % Zero or more characters
# Any single digit (0 — 9)
[listofcharacters] Any single character in listofcharacters
[!listofcharacters] Any single character not in listofcharacters

Examples:

Like "A*" - values that start with the letter A

Like "A????" -values that start with A but have exactly 5 characters

Like "A[d,p]*" - values that start with Ad or Ap

Like "##QR#*" - values that start with 2 digits, then the letters QR, then another digit, followed by any number of other characters. For example, the registration code for a copy of Windows 95 that comes with a new computer has the form #####-OEM-########-#####, where OEM stands for Original Equipment Manufacturer.


Lessons Databases Appendix




Teachers: Request permission to use this site with your class
 
Copyright © 1997-2012 Jan Smith   <jegs1@jegsworks.com>
All Rights Reserved

Icon: DonwloadIcon: CDWant a local copy with no ads? - Download/CD

Want to help?


~~  1 Cor. 10:31 ...whatever you do, do it all for the glory of God.  ~~


Last updated: 30 Apr 2012