Easy question "like"

H

hoachen

I wonder why the 'like" function does not work perperly. In my query i have
want use like to filter out the result. I used like "lightnin" on the
criteria to get the result for which column have this "lightnin" keyword, but
the result shows that it pull the "light, lighthouse, lightbulb, ect". I also
not to put like, just "lightnin" the result were not different. Anyone know
what is going on?
 
K

KARL DEWEY

You have to use a wildcard in place of omited characters.
Like "lightnin?" will pull 'lightning'. -- Single character wildcard.
Like "lightb?" will not pull 'lightbulb'.
Like "light*" will pull 'lightbulb'. -- Multiple character wildcard.
Wildcards can be placed anywhere in the string. -- Like "*ig?t*" will
pull 'slightly'.
 
H

hoachen

nope, it did not work when i use Like "lightnin?" will pull 'lightning'. The
query is from crosstab that you show me.
 
J

John Spencer

Do you want to get the literal string including the question mark? Then you
should be using
= "lightnin?"

Or if you must use like
= "lightnin[?]"
the brackets around the question mark tell the SQL interpreter to look for a
question mark and not use the question mark as a wildcard character.

If you use
Like "Lightnin?"
the results would be any field that started with "lightnin" and had one more
character after that string. So it would match lightning and lightnin' , but
would not match lightnings or lightning storm.


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
H

hoachen

I just want it to match "lightnin s" other than that i don;t want. The like
"lightnin S" did not work properly.

John Spencer said:
Do you want to get the literal string including the question mark? Then you
should be using
= "lightnin?"

Or if you must use like
= "lightnin[?]"
the brackets around the question mark tell the SQL interpreter to look for a
question mark and not use the question mark as a wildcard character.

If you use
Like "Lightnin?"
the results would be any field that started with "lightnin" and had one more
character after that string. So it would match lightning and lightnin' , but
would not match lightnings or lightning storm.


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
nope, it did not work when i use Like "lightnin?" will pull 'lightning'. The
query is from crosstab that you show me.
 
J

Jeff Boyce

Show us the SQL statement you are using -- we can't tell how you are using
"like" and spelling/syntax counts!

Regards

Jeff Boyce
Microsoft Office/Access MVP

hoachen said:
I just want it to match "lightnin s" other than that i don;t want. The like
"lightnin S" did not work properly.

John Spencer said:
Do you want to get the literal string including the question mark? Then
you
should be using
= "lightnin?"

Or if you must use like
= "lightnin[?]"
the brackets around the question mark tell the SQL interpreter to look
for a
question mark and not use the question mark as a wildcard character.

If you use
Like "Lightnin?"
the results would be any field that started with "lightnin" and had one
more
character after that string. So it would match lightning and lightnin' ,
but
would not match lightnings or lightning storm.


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
nope, it did not work when i use Like "lightnin?" will pull
'lightning'. The
query is from crosstab that you show me.

:

You have to use a wildcard in place of omited characters.
Like "lightnin?" will pull 'lightning'. -- Single character
wildcard.
Like "lightb?" will not pull 'lightbulb'.
Like "light*" will pull 'lightbulb'. -- Multiple character
wildcard.
Wildcards can be placed anywhere in the string. -- Like "*ig?t*"
will
pull 'slightly'.

--
Build a little, test a little.


:

I wonder why the 'like" function does not work perperly. In my query
i have
want use like to filter out the result. I used like "lightnin" on the
criteria to get the result for which column have this "lightnin"
keyword, but
the result shows that it pull the "light, lighthouse, lightbulb,
ect". I also
not to put like, just "lightnin" the result were not different.
Anyone know
what is going on?
 
K

KARL DEWEY

The like "lightnin S" did not work properly.
What did it do? What did it not do?

Your post does not show you using any wildcards at all. You must use a
wildcard with 'Like'.

Post your query's SQL as Jeff suggested.

--
Build a little, test a little.


hoachen said:
I just want it to match "lightnin s" other than that i don;t want. The like
"lightnin S" did not work properly.

John Spencer said:
Do you want to get the literal string including the question mark? Then you
should be using
= "lightnin?"

Or if you must use like
= "lightnin[?]"
the brackets around the question mark tell the SQL interpreter to look for a
question mark and not use the question mark as a wildcard character.

If you use
Like "Lightnin?"
the results would be any field that started with "lightnin" and had one more
character after that string. So it would match lightning and lightnin' , but
would not match lightnings or lightning storm.


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
nope, it did not work when i use Like "lightnin?" will pull 'lightning'. The
query is from crosstab that you show me.

:

You have to use a wildcard in place of omited characters.
Like "lightnin?" will pull 'lightning'. -- Single character wildcard.
Like "lightb?" will not pull 'lightbulb'.
Like "light*" will pull 'lightbulb'. -- Multiple character wildcard.
Wildcards can be placed anywhere in the string. -- Like "*ig?t*" will
pull 'slightly'.

--
Build a little, test a little.


:

I wonder why the 'like" function does not work perperly. In my query i have
want use like to filter out the result. I used like "lightnin" on the
criteria to get the result for which column have this "lightnin" keyword, but
the result shows that it pull the "light, lighthouse, lightbulb, ect". I also
not to put like, just "lightnin" the result were not different. Anyone know
what is going on?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top