Using not like  Using wildcard characters as literal characters

Chapter 2: Queries: Selecting Data from a Table

Getting different results using not like and ^

You cannot always duplicate not like patterns with like and the negative wildcard character [^]. Match strings with negative wildcard characters are evaluated in steps, one character at a time. If the match fails at any point in the evaluation, it is eliminated.

For example, this query finds the system tables in a database whose names begin with “sys”:

select name 
from sysobjects 
where name like "sys%" 

If you have a total of 32 objects and like finds 13 names that match the pattern, not like will find the 19 objects that do not match the pattern.

where name not like "sys%"

A pattern such as the following may not produce the same results:

like [^s][^y][^s]%

Instead of 19, you might get only 14, with all the names that begin with “s” or have “y” as the second letter or have “s” as the third letter eliminated from the results, as well as the system table names.





Copyright © 2005. Sybase Inc. All rights reserved. Using wildcard characters as literal characters

View this book as PDF