473,564 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5092

da**********@gm ail.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**********@gm ail.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*******@attgl obal.net
=============== ===
Aug 25 '06 #3
*** da**********@gm ail.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**********@gm ail.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='%program mer%'

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**********@gm ail.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*******@attgl obal.net
=============== ===
Aug 27 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1470
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
1696
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 and put m number of rows in it, but at the end, their 'usage' can not exceed, lets say, x MB. My problem is, how to I evaluate the space being...
1
4468
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
2789
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 this? TIA. Andro
1
1351
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 How would that be "parenthesized" internally in MySQL? What is the rule for precedence between and and or? Thanks IKe
5
2650
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, (@ageraw:=YEAR(CURRENT_DATE()) - YEAR(dateofbirth) -
2
3450
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 : Employee_id, Employee_salary. Please let me know.. I faced this question in an interview and I did not have any answer for this.
4
5673
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", Table "employee", i 've two columns "username" and "password", I've data "admin" and "admin" on both username and the password columns. $u and $p...
2
3089
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 catid='1' and abc>='2007-10-1' and abc<='2007-10-30' here abc is a temp variable can i use it in where clause in same query ?????
2
13206
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: Select Y.ntktno,Y.cpassengername,Y.cfromroute,Y.cuptoroute from t_indi_infiledtl Y,t_indi_cancfiledtl W where Y.ntktno in (select ntktno from...
0
7665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

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.