Re: Case insesnitive searches with postgres
| From: | john slee | Date: | Wed, 20 Sep 2000 23:49:35 +0000 |
| Subject: | Re: Case insesnitive searches with postgres | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-3018@lists.php.net to get a copy of this message | ||
On Wed, Sep 20, 2000 at 06:35:18PM -0400, kerry@noc.suntrix.com wrote:
> I've tried for about a week to get the "~*" identifier to work with
> postgres to do a case insensitive search and haven't gotten it to
> work. Here's the query I'm trying to select:
>
> $result = pg_Exec( $conn, "SELECT DISTINCT author,title,price FROM
> books where author like '%".$Author."%' or title like
> '%".$Title."%'") ;
~* is a regexp compare, which is very different from 'like'.
you want something like
pg_exec($conn, "SELECT DISTINCT author,title,price FROM books
WHERE author ~* '$author' OR title ~* '$title'");
if you put % in, the regexp engine will look for it in the text, which i
don't think is what you want :)
j.
--
.----------+---------------------------------.
|John Slee `-------. <indigoid@chirp.com.au>|
|Chirp Web Design | http://www.chirp.com.au|
|Phone 02 62301871 `--------. 02 62301515 Fax|
`---------------------------+----------------'