Re: string matching in mysql and php
| From: | Hans H. Anderson | Date: | Thu, 14 Sep 2000 20:05:08 +0000 |
| Subject: | Re: string matching in mysql and php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16826@lists.php.net to get a copy of this message | ||
Anna,
You could try '% anna %', but that would eliminate any anna that starts or
ends a record. However, if you selected in a way that would concat a
space on the end and a space on the beginning, that might work. See
concat() in the MySQL documentation for details.
Otherwise, you might consider a full text matching solution. In a
shameless plug, I have such a class (it's free, too, of course):
http://www.hansanderson.com/php/
Hans
On Thu, 14 Sep 2000, Anna Soobrattee wrote:
> hi all,
>
> how can i search my database for a particular occurence of a string?
>
> select * from articles where content like "%anna%" - pulls out
> everything containing the word anna and the substring anna, but i
> would like to pull out article where the content contains the word
> "anna" and not the substring anna.
>
>
> had a look at the REGEXP funtion in the mysql documentation..but i
> don't think i have got the syntax correct.
>
> Can anyone help ?
>
> thanks
> anna
>
>
>
>
>
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>
--
Hans Anderson -=- me@hansanderson.com
http://www.hansanderson.com | PHP, SQL Databases, Flash 5
Animation &
http://www.goofiness.com | Programming, Audio Production,
Brewmeister.