You are here: Re: Generate MySQL "WHERE" clause from a Google-like search string. « PHP Programming Language « IT news, forums, messages
Re: Generate MySQL "WHERE" clause from a Google-like search string.

Posted by NC on 12/17/94 11:56

davehansen22@gmail.com wrote:
>
> Is there a way to generate a MySQL WHERE clause from
> a search string like this:
>
> "(dave OR hansen) php programmer"

Sure. You can devise a regular expression that would transform every
word into field='%word%' and another regular expression that would
replace whitespace not adjacent to an OR with an AND. So the above
phrase would become:

(field='%dave%' OR field='%hansen%') AND field='%php%'
AND field='%programmer%'

which would be a perfect WHERE clause.

Alternatively, you could look into MySQL's full-text search
capabilities:

http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html

> I would want to use the generated MySQL clause against a "memo"
> type field.
>
> I searched but apparently I'm not using the right keywords.

To start with, there is no "memo" field type in MySQL...

Cheers,
NC

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация