473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,403 developers and data experts.

WHERE Clause using Wildcards & Pattern Matching

NeoPa
32,556 Expert Mod 16PB
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 10537

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

Similar topics

100
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...
4
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
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);...
6
by: vpuvvada | last post by:
Please help me out in finding ANSI Standard specification documents for C and C++ Thanks Venkat
5
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...
83
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...
9
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. ...
0
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...
127
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.