Query criteria - the Like operator

G

Guest

I am trying to get records based on text in a Product ID field. In the
select query, in design view, I have criteria as follows: Like "*GAL*". I
am looking for an item that contains the string GAL.

What ends up happening is the operator turns into Alike and it doesn't work.
What is going on here? Why isn't Like a valid operator?


SELECT [Code 10 Production].ItemNum
FROM [Code 10 Production]
WHERE ((([Code 10 Production].ItemNum) ALike "*GAL*"));
 
G

Guest

Like is a valid operator, but Alike is not. What do you mean by "the
operator turns into Alike"?
 
G

Gary Walter

Lambi000 said:
I am trying to get records based on text in a Product ID field. In the
select query, in design view, I have criteria as follows: Like "*GAL*".
I
am looking for an item that contains the string GAL.

What ends up happening is the operator turns into Alike and it doesn't
work.
What is going on here? Why isn't Like a valid operator?


SELECT [Code 10 Production].ItemNum
FROM [Code 10 Production]
WHERE ((([Code 10 Production].ItemNum) ALike "*GAL*"));

It sounds like you apparently have set Options for
SQL Server Compatible Syntax(Ansi92)...

so...

use ALike and "%"

or uncheck it

and use Like and "*"

good luck,

gary
 
G

Guest

When I'm in Design View of a Select Query, I type:

Like "*GAL*"

in the criteria box under the name of the field I want to search.

After typing in the above and moving the cursor, the criteria reads:

ALike "*GAL*"

I didn't type in ALike...I used Like. I'm like totally confused.

Dale Fye said:
Like is a valid operator, but Alike is not. What do you mean by "the
operator turns into Alike"?

Lambi000 said:
I am trying to get records based on text in a Product ID field. In the
select query, in design view, I have criteria as follows: Like "*GAL*". I
am looking for an item that contains the string GAL.

What ends up happening is the operator turns into Alike and it doesn't work.
What is going on here? Why isn't Like a valid operator?


SELECT [Code 10 Production].ItemNum
FROM [Code 10 Production]
WHERE ((([Code 10 Production].ItemNum) ALike "*GAL*"));
 
G

Guest

You are right. I do have that SQL Server Compatible Syntax (ANSI92) option
on. I am dealing with SQL Server tables....does that force me to keep that
option checked?

Thanks....I thought I was losing it.

Gary Walter said:
Lambi000 said:
I am trying to get records based on text in a Product ID field. In the
select query, in design view, I have criteria as follows: Like "*GAL*".
I
am looking for an item that contains the string GAL.

What ends up happening is the operator turns into Alike and it doesn't
work.
What is going on here? Why isn't Like a valid operator?


SELECT [Code 10 Production].ItemNum
FROM [Code 10 Production]
WHERE ((([Code 10 Production].ItemNum) ALike "*GAL*"));

It sounds like you apparently have set Options for
SQL Server Compatible Syntax(Ansi92)...

so...

use ALike and "%"

or uncheck it

and use Like and "*"

good luck,

gary
 
G

Gary Walter

Depends on what you mean by
"dealing with SQL Server tables"

Almost all my projects are mdb's
accessing SQL Server and I don't
check ANSI-92 option.

That may not help you much though...

I might do a search on Google Groups for

Access ANSI-92

and see what some gotchas might be...

sorry,

gary

Lambi000 said:
You are right. I do have that SQL Server Compatible Syntax (ANSI92)
option
on. I am dealing with SQL Server tables....does that force me to keep
that
option checked?

Thanks....I thought I was losing it.

Gary Walter said:
Lambi000 said:
I am trying to get records based on text in a Product ID field. In the
select query, in design view, I have criteria as follows: Like
"*GAL*".
I
am looking for an item that contains the string GAL.

What ends up happening is the operator turns into Alike and it doesn't
work.
What is going on here? Why isn't Like a valid operator?


SELECT [Code 10 Production].ItemNum
FROM [Code 10 Production]
WHERE ((([Code 10 Production].ItemNum) ALike "*GAL*"));

It sounds like you apparently have set Options for
SQL Server Compatible Syntax(Ansi92)...

so...

use ALike and "%"

or uncheck it

and use Like and "*"

good luck,

gary
 

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