470,848 Members | 1,216 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

ODBC Query of Access 2000 db using LIKE

Attempting to query MS Access database with the ODBC drivers for PHP. When
using the LIKE statement no records are returned.

Example:

$query = " Select * From Dispatch Where Customer Like '*A*' ";
$result = odbc_prepare($db,$query);
odbc_execute($result);

Does anyone out there know the syntax that I should be using for the Like
statement in the Where clause? When I do a normal query, it works
fine....Just using wildcards it does not work....
Jul 17 '05 #1
5 4225
Jahmil Richardson <ja****@thehelpesk.com> wrote:
$query = " Select * From Dispatch Where Customer Like '*A*' ";

Does anyone out there know the syntax that I should be using for the Like
statement in the Where clause? When I do a normal query, it works
fine....Just using wildcards it does not work....


It works perfectly, you are just to lazy to search for a correct
example:
http://www.google.com/search?q=sql+l...ldcard+example

First link explains it all.

--

Daniel Tryba

Jul 17 '05 #2
I noticed that Message-ID: <c6**********@news.tue.nl> from Daniel Tryba
contained the following:
Jahmil Richardson <ja****@thehelpesk.com> wrote:
$query = " Select * From Dispatch Where Customer Like '*A*' ";

Does anyone out there know the syntax that I should be using for the Like
statement in the Where clause? When I do a normal query, it works
fine....Just using wildcards it does not work....


It works perfectly, you are just to lazy to search for a correct
example:
http://www.google.com/search?q=sql+l...ldcard+example


That's unfair. Access databases use the asterisk as a wild card.

I've not written a LIKE query with my ODBC setup so I can't help I'm
afraid.

It may be an idea to try the % though.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
Geoff Berrow <bl******@ckdog.co.uk> wrote:
$query = " Select * From Dispatch Where Customer Like '*A*' ";

Does anyone out there know the syntax that I should be using for the Like
statement in the Where clause? When I do a normal query, it works
fine....Just using wildcards it does not work....


It works perfectly, you are just to lazy to search for a correct
example:
http://www.google.com/search?q=sql+l...ldcard+example


That's unfair. Access databases use the asterisk as a wild card.


If that is correct, that I appologize to the OP.

--

Daniel Tryba

Jul 17 '05 #4
Sadly, that IS correct. Access hath its quirks.
IIRC, Access needs the token string to be surrounded by double quotes, so
perhaps the OP could try rewriting the query as:
$query = 'Select * From Dispatch Where Customer Like "*A*"';

HTH
Doug

--
Remove the blots from my address to reply
"Daniel Tryba" <ne**************@canopus.nl> wrote in message
news:c6**********@news.tue.nl...
Geoff Berrow <bl******@ckdog.co.uk> wrote:
$query = " Select * From Dispatch Where Customer Like '*A*' ";

Does anyone out there know the syntax that I should be using for the Like statement in the Where clause? When I do a normal query, it works
fine....Just using wildcards it does not work....

It works perfectly, you are just to lazy to search for a correct
example:
http://www.google.com/search?q=sql+l...ldcard+example


That's unfair. Access databases use the asterisk as a wild card.


If that is correct, that I appologize to the OP.

--

Daniel Tryba

Jul 17 '05 #5
Ooops.. typo..
$query = 'Select * From Dispatch Where Customer Like \"*A*\"';
"8-{
--
Remove the blots from my address to reply
"Doug Hutcheson" <do*****************@nrm.blot.qld.blot.gov.blot.au > wrote
in message news:XK******************@news.optus.net.au...
Sadly, that IS correct. Access hath its quirks.
IIRC, Access needs the token string to be surrounded by double quotes, so
perhaps the OP could try rewriting the query as:
$query = 'Select * From Dispatch Where Customer Like "*A*"';

HTH
Doug

--
Remove the blots from my address to reply
"Daniel Tryba" <ne**************@canopus.nl> wrote in message
news:c6**********@news.tue.nl...
Geoff Berrow <bl******@ckdog.co.uk> wrote:
>> $query = " Select * From Dispatch Where Customer Like '*A*' ";
>>
>> Does anyone out there know the syntax that I should be using for the Like>> statement in the Where clause? When I do a normal query, it works
>> fine....Just using wildcards it does not work....
>
>It works perfectly, you are just to lazy to search for a correct
>example:
>http://www.google.com/search?q=sql+l...ldcard+example

That's unfair. Access databases use the asterisk as a wild card.


If that is correct, that I appologize to the OP.

--

Daniel Tryba


Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Tim | last post: by
8 posts views Thread by Alfonso Esteban Gonzalez Sencion | last post: by
4 posts views Thread by Dave | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.