Sunday, April 02, 2006

Using Wildcards in Queries

The GTViewer family of products (GTViewer, Pocket GTViewer, GTVx, and GTWeb) has always provided support for Wildcards (*) in queries. Wildcards allow you to only enter part of the value you are searching far and give you more flexibility when performing a query.

By default, all queries perform a “Begins With” search. If you enter the first part of a value you are searching for, the query will return all records that begin with the value you entered. There are, however, several modes you can use when searching: Begins With, Ends With, Contains, and Exact Match. To illustrate these different search modes, each mode will be described below.

Let us say you are looking for records with the value: 123456789

You could enter just 1234 in the query prompt. Since a “Begins With” search is the default, you do not have to add the Wildcard at the end of the prompt value, but 1234* is the equivalent search string and both it and 1234 will return all records whose values begin with 1234 such as 123456789, 123400000, 12345555, 1234, etc.

You can also perform an “Ends With” search by placing the wildcard at the beginning, such as *6789 which will return 123456789 but also all records that end with 6789 such as 0006789, 111116789, 6789, etc.

The “Contains” search is a combination of the “Begins With” and the “Ends With” search modes. This mode is specified by placing a Wildcard at the beginning and end of the prompt value. So, if you specify *456*, you will get all records that contain 456 in their value such as 123456789, 111456111, 456, 456789, 123456, etc.

Lastly, the “Exact Match” search method is a way to get around the default "Begins With" search if that is not what you want. By specifying a tick mark at the beginning and end of a prompt value, such as '123456789', you will only get records returned that have a value of 123456789.

To summarize these modes, the following list shows how to specify the different search modes. The xxxx is the text you enter for the prompt:

xxxx automatically does a begins with
xxxx* begins with (same as default)
*xxxx ends with
*xxxx* contains
'xxxx' exact match

No comments: