Query with Like

T

Tausif

Hi,

I have created following query.. but i would like to know how we can use %%
with the [Keyword] variable at where clause. I tried %[Keyword]% but its
giving me error.

PARAMETERS KeyWord Text ( 255 );
SELECT transactions.ChangeRequest, transactions.Priority, transactions.ID,
transactions.[Problem No] AS TicketNo
FROM transactions
WHERE (transactions.ProblemDesc like [KeyWord] OR transactions.ChangeRequest
like [KeyWord]);
 
V

Van T. Dinh

In JET, the Wildcards are * (group of chars) and ? (single chr) useless you
use ADO code to run the SQL.

PARAMETERS KeyWord Text ( 255 );
SELECT transactions.ChangeRequest, transactions.Priority, transactions.ID,
transactions.[Problem No] AS TicketNo
FROM transactions
WHERE (transactions.ProblemDesc like "*" & [KeyWord] * "*")
OR (transactions.ChangeRequest like "*" & [KeyWord] & "*");

HTH
Van T. Dinh
MVP (Access)
 
T

Tausif

Hi, Dinh,

I am not using Jet. Just like to store the query with wildcard in access
Query. If any buddy like to execute it just double click the query and put
the keyword.

I tried both * & %. Both giving me the same error message. syntax error..
and wont allow me to save the query.

Tausif

Van T. Dinh said:
In JET, the Wildcards are * (group of chars) and ? (single chr) useless you
use ADO code to run the SQL.

PARAMETERS KeyWord Text ( 255 );
SELECT transactions.ChangeRequest, transactions.Priority, transactions.ID,
transactions.[Problem No] AS TicketNo
FROM transactions
WHERE (transactions.ProblemDesc like "*" & [KeyWord] * "*")
OR (transactions.ChangeRequest like "*" & [KeyWord] & "*");

HTH
Van T. Dinh
MVP (Access)



Tausif said:
Hi,

I have created following query.. but i would like to know how we can use %%
with the [Keyword] variable at where clause. I tried %[Keyword]% but its
giving me error.

PARAMETERS KeyWord Text ( 255 );
SELECT transactions.ChangeRequest, transactions.Priority, transactions.ID,
transactions.[Problem No] AS TicketNo
FROM transactions
WHERE (transactions.ProblemDesc like [KeyWord] OR transactions.ChangeRequest
like [KeyWord]);
 
J

John Vinson

Hi, Dinh,

I am not using Jet.

If you're using an Access .mdb database, you ARE using JET - that's
the database engine behind Access. Do you mean that you have the data
stored externally in SQL/Server or some other database engine?
Just like to store the query with wildcard in access
Query. If any buddy like to execute it just double click the query and put
the keyword.
I tried both * & %. Both giving me the same error message. syntax error..
and wont allow me to save the query.

Please copy and paste the actual SQL view of the query that's giving
you the error.

John W. Vinson[MVP]
 
G

Gary Walter

PMFBI
In the message I received here there
may be a typo -- extra * instead of &...

PARAMETERS KeyWord Text ( 255 );
SELECT transactions.ChangeRequest, transactions.Priority, transactions.ID,
transactions.[Problem No] AS TicketNo
FROM transactions
WHERE (transactions.ProblemDesc like "*" & [KeyWord] & "*")
OR (transactions.ChangeRequest like "*" & [KeyWord] & "*");

Apologies for buttinginness,

gary

In JET, the Wildcards are * (group of chars) and ? (single chr) useless
you
use ADO code to run the SQL.

PARAMETERS KeyWord Text ( 255 );
SELECT transactions.ChangeRequest, transactions.Priority, transactions.ID,
transactions.[Problem No] AS TicketNo
FROM transactions
WHERE (transactions.ProblemDesc like "*" & [KeyWord] * "*")
OR (transactions.ChangeRequest like "*" & [KeyWord] & "*");

HTH
Van T. Dinh
MVP (Access)



Tausif said:
Hi,

I have created following query.. but i would like to know how we can use %%
with the [Keyword] variable at where clause. I tried %[Keyword]% but its
giving me error.

PARAMETERS KeyWord Text ( 255 );
SELECT transactions.ChangeRequest, transactions.Priority,
transactions.ID,
transactions.[Problem No] AS TicketNo
FROM transactions
WHERE (transactions.ProblemDesc like [KeyWord] OR transactions.ChangeRequest
like [KeyWord]);
 
V

Van T. Dinh

Yep.

Thanks, Gary.

Cheers
Van T. Dinh



Gary Walter said:
PMFBI
In the message I received here there
may be a typo -- extra * instead of &...

PARAMETERS KeyWord Text ( 255 );
SELECT transactions.ChangeRequest, transactions.Priority, transactions.ID,
transactions.[Problem No] AS TicketNo
FROM transactions
WHERE (transactions.ProblemDesc like "*" & [KeyWord] & "*")
OR (transactions.ChangeRequest like "*" & [KeyWord] & "*");

Apologies for buttinginness,

gary

In JET, the Wildcards are * (group of chars) and ? (single chr) useless
you
use ADO code to run the SQL.

PARAMETERS KeyWord Text ( 255 );
SELECT transactions.ChangeRequest, transactions.Priority, transactions.ID,
transactions.[Problem No] AS TicketNo
FROM transactions
WHERE (transactions.ProblemDesc like "*" & [KeyWord] * "*")
OR (transactions.ChangeRequest like "*" & [KeyWord] & "*");

HTH
Van T. Dinh
MVP (Access)



Tausif said:
Hi,

I have created following query.. but i would like to know how we can
use
%%
with the [Keyword] variable at where clause. I tried %[Keyword]% but its
giving me error.

PARAMETERS KeyWord Text ( 255 );
SELECT transactions.ChangeRequest, transactions.Priority,
transactions.ID,
transactions.[Problem No] AS TicketNo
FROM transactions
WHERE (transactions.ProblemDesc like [KeyWord] OR transactions.ChangeRequest
like [KeyWord]);
 

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