ODBC Query of Access 2000 db using LIKE

This is a discussion on ODBC Query of Access 2000 db using LIKE within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Attempting to query MS Access database with the ODBC drivers for PHP. When using the LIKE statement no records are ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-27-2004
Jahmil Richardson
 
Posts: n/a
Default 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....
Reply With Quote
  #2 (permalink)  
Old 04-27-2004
Daniel Tryba
 
Posts: n/a
Default Re: ODBC Query of Access 2000 db using LIKE

Jahmil Richardson <jahmil@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

Reply With Quote
  #3 (permalink)  
Old 04-27-2004
Geoff Berrow
 
Posts: n/a
Default Re: ODBC Query of Access 2000 db using LIKE

I noticed that Message-ID: <c6m6ki$qfc$2@news.tue.nl> from Daniel Tryba
contained the following:

>Jahmil Richardson <jahmil@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/
Reply With Quote
  #4 (permalink)  
Old 04-27-2004
Daniel Tryba
 
Posts: n/a
Default Re: ODBC Query of Access 2000 db using LIKE

Geoff Berrow <blthecat@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

Reply With Quote
  #5 (permalink)  
Old 05-04-2004
Doug Hutcheson
 
Posts: n/a
Default Re: ODBC Query of Access 2000 db using LIKE

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" <news_alt.php.sql@canopus.nl> wrote in message
news:c6m8hp$rdo$2@news.tue.nl...
> Geoff Berrow <blthecat@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
>



Reply With Quote
  #6 (permalink)  
Old 05-05-2004
Doug Hutcheson
 
Posts: n/a
Default Re: ODBC Query of Access 2000 db using LIKE

Ooops.. typo..
$query = 'Select * From Dispatch Where Customer Like \"*A*\"';
"8-{


--
Remove the blots from my address to reply
"Doug Hutcheson" <doug.blot.hutcheson@nrm.blot.qld.blot.gov.blot.au > wrote
in message news:XKUlc.1847$IH5.84692@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" <news_alt.php.sql@canopus.nl> wrote in message
> news:c6m8hp$rdo$2@news.tue.nl...
> > Geoff Berrow <blthecat@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
> >

>
>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:22 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0