473,756 Members | 5,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WHERE Clause using Wildcards & Pattern Matching

NeoPa
32,572 Recognized Expert Moderator MVP
ANSI-89 v ANSI-92
Before we get into all the various types of pattern matching that can be used, there are two ANSI standards used for the main types of wildcard matching (matching zero or more characters or simply matching a single character) :
ANSI-89 - Mainly used only by Jet / ACE SQL
ANSI-92 - Mainly used by SQL Server and other grown-up products
In the later versions of Access it is now possible to select ANSI-92 compatibility as an option, instead of the ANSI-89 compatibility.

Using Wildcard Characters in String Comparisons
Built-in pattern matching provides a versatile tool for making string comparisons. The following table shows the wildcard characters you can use with the Like operator and the number of digits or strings they match.

Pattern Match Character(s) in expressions :
Any single character - '?' [ANSI-89] or '_' (underscore) [ANSI-92]
Zero or more characters - '*' [ANSI-89] or '%' [ANSI-92]
Any single digit (0 - 9) - '#'
Any single character found within charlist - [charlist]
Any single character not found within charlist - [!charlist]

You can use a group of one or more characters (charlist) enclosed in brackets ([ ]) to match any single character in an expression, and charlist can include almost any characters in the ANSI character set, including digits. You can use the special characters opening bracket ([ ), question mark (?), underscore (_), asterisk (*), percent (%) and number sign (#) to match themselves directly only if enclosed in brackets. You cannot use the closing bracket (]) within a group to match itself, but you can use it outside a group as an individual character.

In addition to a simple list of characters enclosed in brackets, charlist can specify a range of characters by using a hyphen (-) to separate the upper and lower bounds of the range. For example, using [A-Z] in a pattern results in a match if the corresponding character position in the expression contains any of the uppercase letters in the range A through Z. You can include multiple ranges within the brackets without delimiting the ranges. For example, [a-zA-Z0-9] matches any alphanumeric character.

It is important to note that the ANSI-92 SQL wildcards (%) and (_) are only available with Microsoft® Jet version 4.X and the Microsoft OLE DB Provider for Jet. They will be treated as literals if used through Microsoft Access or DAO.

Other important rules for pattern matching include the following :

An exclamation mark (!) at the beginning of charlist means that a match is made if any character except those in charlist are found in the expression. When used outside brackets, the exclamation mark matches itself.
You can use the hyphen (-) either at the beginning (after an exclamation mark if one is used) or at the end of charlist to match itself. In any other location, the hyphen identifies a range of ANSI characters.
When you specify a range of characters, the characters must appear in ascending sort order (A-Z or 0-100). [A-Z] is a valid pattern, but [Z-A] is not.
The character sequence [] is ignored; it is considered to be a zero-length string ("").
Jul 13 '07 #1
0 10591

Sign in to post your reply or Sign up for a free account.

Similar topics

100
7016
by: Roose | last post by:
Just to make a tangential point here, in case anyone new to C doesn't understand what all these flame wars are about. Shorthand title: "My boss would fire me if I wrote 100% ANSI C code" We are discussing whether this newsgroup should focus on 100% ANSI C or simply topics related to the C language in the real world. There is a C standard which is defined by an international committee. People who write compilers refer to this in...
4
3751
by: Luke Wu | last post by:
I am just wondering what the following terms usually mean: 1) "Standard C" 2) "K&R C" 3) "ANSI C" I am pretty sure "ANSI C" usually refers to the C89 standard, but what
13
4345
by: Roy Hills | last post by:
I've seen two different function prototype formats used for ANSI C, and I'm unsure as to which is the correct or preferred one. 1st Format (this is what I use) type function(type, type, type); e.g. "int multiply(int, int);" 2nd Format (I've seen this used in other people's code)
6
2098
by: vpuvvada | last post by:
Please help me out in finding ANSI Standard specification documents for C and C++ Thanks Venkat
5
8849
by: alsor.zhou | last post by:
hi all, I'm searching the `ANSI C89 specification' and the related. Since I tried with `ansi c89 standard' and `ansi c89 specificatioin' in google, there was none useful links return. anybody here could do me a fever to show me a link or send me a copy? Thanks and best regards, alsor
83
11620
by: sunny | last post by:
Hi All What is C99 Standard is all about. is it portable, i mean i saw -std=C99 option in GCC but there is no such thing in VC++.? which one is better ANSI C / C99? can i know the major difference between C99 & ANSI C standards?
9
13650
by: emagzz | last post by:
Hi all, I need to convert many text file from ANSI to UNICODE. Some body knows if there is a free utility that can do this from the command line so as I can use it inside a batch file. Thank you Emanuele
0
3054
by: MaartenVR | last post by:
sub: MS SQL server and (missing) ANSI DATE-datatype I’m working at a company who has developed a large client/server application in Delphi 6, with Interbase as the DB-server (both Borland products). As data-access technology we use dbExpress (from Borland) because it is claimed to be database-independent. Now we have a new customer who wants to use MS SQL-server and I investigated if this was possible. Unfortunately my conclusion is that it...
127
5510
by: bz800k | last post by:
Hi Does this code satisfy ANSI C syntax ? void function(void) { int a = 2; a = ({int c; c = a + 2;}); /* <<-- here !! */ printf("a=%d\n", a);
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9869
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5140
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2665
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.