473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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

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
5 5077

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
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
*** 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
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: frizzle | last post by:
Hi there, I can not seem to figure out where to put my WHERE clause in the next query: SELECT s.id, s.kind_id, s.active, s.name, COUNT(p.id) AS 'quantity' FROM pr_series s
2
by: Manish Pandit | last post by:
Hi, I have tried looking for a solution to this problem but no luck. The thing is, in my system, I have a set of users who have a 'quota' limiting their usage. They can create n number of tables...
1
by: Tom Louchbaum | last post by:
Can someonw pls tell me how to reference the Where clause made by the VBA statement DoCmd.OPENREPORT "Report",acviewpreview,,where as a control within the Report itself? Thanks.
13
by: andro | last post by:
Hi everybody! I have several tables from which I want to exract the SAME value (along with other referenced data). All the values are in the same column within the tables. How can I achieve...
1
by: Ike | last post by:
I cannot find now, what the precedence is in the where clause of a select statement, where "AND" and "OR" are mixed in, and there are no parentheses. For example: WHERE a=1 and b=2 or c=3 ...
5
by: pwiegers | last post by:
Hi, I'm trying to use the result of a conditional statement in a where clause, but i'm getting 1)nowhere 2) desperate :-) The query is simple: -------- SELECT idUser,...
2
by: santoshsri | last post by:
Hello, Is there any by which I can write a SQL to get the 4th largest salary from a table without using "join" and without using "where" clause. Suppose the table is having two columns :...
4
by: karthikeyanck | last post by:
I'm a newbie, I've installed PHP, Apache and MySQL on my Ubuntu system I've trouble in quering the data from MySQL when using the query function within PHP. I 've created a Database "test",...
2
sanjay123456
by: sanjay123456 | last post by:
Dear friends, see the Following query ----- SELECT headline, Concat(EXTRACT(YEAR FROM datetime),'-',EXTRACT(MONTH FROM datetime),'-',DAYOFMONTH(datetime)) as abc FROM news_news where...
2
by: vinayakkale2 | last post by:
Hi I am using a select query from front end to generate report in such a way that I should be able to get records of Table W which are present in Table Y The query which i am using is as follows: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.