Page 501 - Microsoft Office Excel 2003 Programming Inside Out
P. 501

Excel and the Structured Query Language

                             Table 22-1.  Wildcard Characters in Access
                             Character     Meaning                       Examples
                             #             Matches a single digit.       A#
                                                                         True: A0, A9
                                                                         False: AA, A00
                             []	           Matches the character or range of   A[*]A
                                           characters specified inside the   True: A*A
                                           brackets. Remember that using an   False: AAA
                                           exclamation point (!) means that the  A[D-F]A
                                           characters outside the range will   True: ADA, AFA
                                           match the value.              False: AAA, ADAA
                                                                         A[!0-9]
                                                                         True: AA, AB
                                                                         False: A0, A9

                             When possible, try to limit the use of the Like operators to those columns that are part of an
                             index. Without the index, the database might have to examine each and every row to find the
                             rows that match. And, even with an index, you’ll get the best performance if you use the wild-
                             card characters at the end of the search string.

                             Note  Every database system has its own unique set of wildcard characters. For instance,
                             the * used by Access is the % in SQL Server. Be sure to make sure that you’re using the
                             proper wildcard characters in your program.
                                                                                                             Chapter 22

                    Sorting Rows
                             One of the architectural quirks of a relational database is that the database server is free to
                             return rows in any order. However, you can use the Order By clause to force the database
                             server to return in the order you specify. For example, the following Select statement retrieves
                             all the customers from the database in Zip code order:

                             Select Name, Street, City, State, Zip
                             From Customers
                             Order By ZipCode

                             This Select statement will sort the rows first by Zip code and then within each Zip code by
                             customer’s name.

                             Select Name, Street, City, State, Zip
                             From Customers
                             Order By ZipCode, Name






                                                                                                       475
                                                                        Part 6:  Excel and the Outside World: Collaborating Made Easy
   496   497   498   499   500   501   502   503   504   505   506