ODBC Query of Access 2000 db using LIKE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jahmil Richardson

    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($d b,$query);
    odbc_execute($r esult);

    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....
  • Daniel Tryba

    #2
    Re: ODBC Query of Access 2000 db using LIKE

    Jahmil Richardson <jahmil@thehelp esk.com> wrote:[color=blue]
    > $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....[/color]

    It works perfectly, you are just to lazy to search for a correct
    example:


    First link explains it all.

    --

    Daniel Tryba

    Comment

    • Geoff Berrow

      #3
      Re: ODBC Query of Access 2000 db using LIKE

      I noticed that Message-ID: <c6m6ki$qfc$2@n ews.tue.nl> from Daniel Tryba
      contained the following:
      [color=blue]
      >Jahmil Richardson <jahmil@thehelp esk.com> wrote:[color=green]
      >> $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....[/color]
      >
      >It works perfectly, you are just to lazy to search for a correct
      >example:
      >http://www.google.com/search?q=sql+l...ldcard+example[/color]

      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/

      Comment

      • Daniel Tryba

        #4
        Re: ODBC Query of Access 2000 db using LIKE

        Geoff Berrow <blthecat@ckdog .co.uk> wrote:[color=blue][color=green][color=darkred]
        >>> $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....[/color]
        >>
        >>It works perfectly, you are just to lazy to search for a correct
        >>example:
        >>http://www.google.com/search?q=sql+l...ldcard+example[/color]
        >
        > That's unfair. Access databases use the asterisk as a wild card.[/color]

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

        --

        Daniel Tryba

        Comment

        • Doug Hutcheson

          #5
          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.s ql@canopus.nl> wrote in message
          news:c6m8hp$rdo $2@news.tue.nl. ..[color=blue]
          > Geoff Berrow <blthecat@ckdog .co.uk> wrote:[color=green][color=darkred]
          > >>> $query = " Select * From Dispatch Where Customer Like '*A*' ";
          > >>>
          > >>> Does anyone out there know the syntax that I should be using for the[/color][/color][/color]
          Like[color=blue][color=green][color=darkred]
          > >>> 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[/color]
          > >
          > > That's unfair. Access databases use the asterisk as a wild card.[/color]
          >
          > If that is correct, that I appologize to the OP.
          >
          > --
          >
          > Daniel Tryba
          >[/color]


          Comment

          • Doug Hutcheson

            #6
            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.hutc heson@nrm.blot. qld.blot.gov.bl ot.au> wrote
            in message news:XKUlc.1847 $IH5.84692@news .optus.net.au.. .[color=blue]
            > 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.s ql@canopus.nl> wrote in message
            > news:c6m8hp$rdo $2@news.tue.nl. ..[color=green]
            > > Geoff Berrow <blthecat@ckdog .co.uk> wrote:[color=darkred]
            > > >>> $query = " Select * From Dispatch Where Customer Like '*A*' ";
            > > >>>
            > > >>> Does anyone out there know the syntax that I should be using for the[/color][/color]
            > Like[color=green][color=darkred]
            > > >>> 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.[/color]
            > >
            > > If that is correct, that I appologize to the OP.
            > >
            > > --
            > >
            > > Daniel Tryba
            > >[/color]
            >
            >[/color]


            Comment

            Working...