By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Generate MySQL "WHERE" clause from a Google-like search string.

P: n/a
Is there a way to generate a MySQL WHERE clause from a search string
like this:

"(dave OR hansen) php programmer"

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.

Any help.......

Dave

Aug 25 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a

da**********@gmail.com wrote:
Is there a way to generate a MySQL WHERE clause from a search string
like this:

"(dave OR hansen) php programmer"

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.
Can you post the table definition and full query you were trying?

Aug 25 '06 #2

P: n/a
da**********@gmail.com wrote:
Is there a way to generate a MySQL WHERE clause from a search string
like this:

"(dave OR hansen) php programmer"

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.

Any help.......

Dave
Might I suggest a MySQL newsgroup - such as comp.databases.mysql? This
one is for PHP questions...

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 25 '06 #3

P: n/a
*** da**********@gmail.com escribió/wrote (25 Aug 2006 10:00:23 -0700):
Is there a way to generate a MySQL WHERE clause from a search string
like this:

"(dave OR hansen) php programmer"
Find a PHP application called osCommerce and have a look at its source
code. It has an internal search engine that allows parenthesis and boolean
operators.

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 25 '06 #4

P: n/a
NC
da**********@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/...xt-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

Aug 25 '06 #5

P: n/a

Jerry Stuckle wrote:
da**********@gmail.com wrote:
Is there a way to generate a MySQL WHERE clause from a search string
like this:

"(dave OR hansen) php programmer"

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.

Any help.......

Dave

Might I suggest a MySQL newsgroup - such as comp.databases.mysql? This
one is for PHP questions...
Thanks but I was hoping to find a canned PHP (function, snippet, class,
whatever) that was already tested. That is why I asked this question
in the PHP group.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 27 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.