Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using like operator on a column/field

Status
Not open for further replies.

mhoek74

Programmer
May 6, 2003
5
US
Hello,

In an Access query, I would like to use the like operator (or a variation) on a field rather than a string.

For example,

SELECT table_a.x
FROM table_a, table_b
WHERE table_a.x like table_b.y

Is something like this possible?

Thanks!
Mike

 
yes.

the sql version looks like this:
Code:
SELECT table_a.x
FROM [table_a], [table_b]
WHERE (((table_a.x) Like "*" & table_b.y & "*"))

put both tables into a new query grid window
dont make any join on them.
in the criteria for whatever you are looking for in one table, put
Code:
like "*" & table_b.y & "*"

the asterisks tell Access to find any match where the thing you're searching for is anywhere in the data you're searching IN.

other uses are to just put the * at the front, or just at the back.
so if you are looking at this data
ABCDE
BBBEE

and you put
*B*: all of them will be returned cause they both contain B anywhere
B* : only the second one will be returned cause it starts with B
*E : both again will be returned cause they both end in E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top