Posted by NC on 11/11/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
[Back to original message]
|