Re: Not like query

From: Tom Ellison (tellison_at_jcdoyle.com)
Date: 08/19/04


Date: Thu, 19 Aug 2004 13:21:40 -0500

Dear Rick:

To place an otherwise wildcard character in a search string but use
its literal value, place it inside square brackets:

To exclude anything beginning with 3 asterisks:

NOT LIKE "[*][*][*]%"

or

NOT LIKE "[*][*][*]*"

The first is for MSDE or SQL Server, the latter for Jet databases.

However, asterisk is not a special character in the first case, so it
is sufficient to use:

NOT LIKE "***%"

Another way would be:

LEFT(FieldName, 3) <> "***"

When you don't use "LIKE" there are no special characters with which
to be concerned.

If in doubt, use more than one technique and compare the number of
rows returned.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts

On Thu, 19 Aug 2004 10:37:50 -0700, "Rick"
<anonymous@discussions.microsoft.com> wrote:

>I have a list which includes several names which begin
>with the asterisk character. For example:
>
>***
>*** School
>*** Illness
>*** Vacation
>Job Assignment
>Course Instructor
>*** Time Off Personal
>Travel
>
>I am attempting to write a query to exclude anything in
>the list beginning with three asterisks "***"
>
>I have attempted to use literals and ANSI character set
>chr(42)for * and chr(37) for % without success.
>
>The criteria I have attempted:
>
>Not chr(42) & chr(42) & chr(42) & chr(37)
>Not "*" & "*" & "*" & "%"
>Not (*) & (*) & (*) & (%)
>
>Can anyone suggest the correct syntax for this criteria.
>
>TIA



Relevant Pages

  • RE: String Manipulation
    ... escaped asterisk. ... The slash is still special because it's the regexp ... The square brackets are a character class. ...
    (perl.beginners)
  • Re: use of * jolly character
    ... If you're looking for a field containing only one character, an asterisk, ... in the criteria line will work. ... If you're looking for an asterisk anywhere within a text string, ... than a wildcard: ...
    (microsoft.public.access.queries)
  • Re: finding specific sequence of wildcard characters
    ... to find single instances of the "*" character (i.e., the asterisk ... please post all follow-ups to the newsgroup so ...
    (microsoft.public.word.docmanagement)
  • Re: Message ID with mySQL?
    ... > conventions change. ... Hence the asterisk (or some other character that will do the job). ...
    (alt.html)
  • Re: Bash: Asterisk reading problem
    ... Pan wrote: ... character from a set of data files. ... the asterisk symbol, which is causing problems with the exporting process. ...
    (uk.comp.os.linux)