Using LIKE to Perform Access DB Queries

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
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.
 
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 '*'.
 
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
 
Back
Top