Using LIKE to Perform Access DB Queries

N

Nathan Sokalski

I am trying to perform a query in Access using the LIKE operator. When I use
the following SQL command:


SELECT members.organization, artists.artist, artists.email, artists.website
FROM members INNER JOIN artists ON members.memberid = artists.memberid WHERE
(((members.county)='Berks'));


I recieve the results that I want. However, when I use the following SQL
command:


SELECT members.organization, artists.artist, artists.email, artists.website
FROM members INNER JOIN artists ON members.memberid = artists.memberid WHERE
(((members.county) Like '%e%'));


I recieve no results. Shouldn't this return all records in which the
members.county field contains an e (which would include the results from my
first query)? What is the problem here? Any help would be appreciated.
Thanks.
 
B

Brendan Reynolds

If you were executing the query via ADO, you would use the ANSI standard
wildcard '%' as in your example. But when executing the query via DAO or the
graphical query interface in an MDB (which I believe uses DAO behind the
scenes, but don't quote me) you need to use the Jet wildcard '*'.
 
B

Bob Reinkemeyer

Nathan Sokalski said:
I am trying to perform a query in Access using the LIKE operator. When I use
the following SQL command:


SELECT members.organization, artists.artist, artists.email, artists.website
FROM members INNER JOIN artists ON members.memberid = artists.memberid WHERE
(((members.county)='Berks'));


I recieve the results that I want. However, when I use the following SQL
command:


SELECT members.organization, artists.artist, artists.email, artists.website
FROM members INNER JOIN artists ON members.memberid = artists.memberid WHERE
(((members.county) Like '%e%'));


I recieve no results. Shouldn't this return all records in which the
members.county field contains an e (which would include the results from my
first query)? What is the problem here? Any help would be appreciated.
Thanks.
this one works for me...
SELECT TemplateNumber,Pitch, NumberTeeth, RollerDiameter," _

& "SidebarHeight,ChainNumber,ChainType,PitchDiameter" _

& " FROM sprockettemplates WHERE ChainNumber LIKE " & "'%" & m_sSChainNumber & "%'" _

& " AND MachineCut = false AND SplitPitch = false" _

& " ORDER BY Pitch, NumberTeeth, RollerDiameter"

This will get all before and after the variable. Delete one or the other if you only need wildcard before or after variable.



Hope this helps,



Bob
 

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