Home > Archive > MS Access and Internet > July 2005 > Using LIKE to Perform Access DB Queries









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Using LIKE to Perform Access DB Queries
Nathan Sokalski

2005-07-10, 8:24 pm

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.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/


Brendan Reynolds

2005-07-10, 8:24 pm

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 '*'.

--
Brendan Reynolds (MVP)


"Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
news:OIfvoVZhFHA.2852@TK2MSFTNGP15.phx.gbl...
>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.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>



Bob Reinkemeyer

2005-07-11, 7:24 am


"Nathan Sokalski" <njsokalski@hotmail.com> wrote in message news:OIfvoVZhFHA.2852@TK2MSFTNGP15.phx.gbl...
> 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.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
>

this one works for me...
SELECT TemplateNumber,Pitch
, NumberTeeth, RollerDiameter," _

& " SidebarHeight,ChainN
umber,ChainType,Pitc
hDiameter" _

& " 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


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com