How do I make a contains query

cayham86

Member
Local time
Today, 13:52
Joined
Jun 30, 2022
Messages
54
Hey guys,

I am trying to make a query which contains certain information so wondering how do I write a contains query?
 
Use the Like criteria?
Tried that and it didn't work as it needs to contain part of a bit of text which isn't at the start of the description but in the middle of the description
 
you can also try Instr() function, eg:

Select * From yourTable Where Instr(1, [yourField], "theTextToFind") <> 0
 
Instr() is an Access function and I've used that many times in Access Query.
there is no harm on Testing it.

btw Like will work, why did it not?

select * from yourTable where [field1] Like "*yourText*"
 
Instr() is an Access function and I've used that many times in Access Query.
there is no harm on Testing it.

btw Like will work, why did it not?

select * from yourTable where [field1] Like "*yourText*"
Like didn't bring back any results
 
Ill have another try later
I really cannot see why Like *text* will not work? :(
Code:
SELECT Transactions.*, Transactions.Description
FROM Transactions
WHERE (((Transactions.Description) Like "*ill*"));

1657439608762.png
 
I am trying to make a query which contains certain information

Best avoid using the word "contains" in this context. CONTAINS predicate is used in SQL Server and not supported by Access/ACE which doesn't have Full Text Indexing.

Like or InStr() should definitely do the job. You really should show the actual SQL you used.
Could you be getting the search criteria out of another field or control and not concatenating it properly?
 

Users who are viewing this thread

Back
Top Bottom