473,785 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multi-word query

Hello all, I'm trying to figure out how to search a "key_words" column,
that contain key words (obviously) for that row. An example of what one
of the key_words contains is: "home interior decorating". I can search
for "home interior" or "interior decorating" and it will return the
correct row, but if I search for "interior home" or "home decorating" I
get nothing. I need it to return any row with ALL of those words in any
order. I am using WHERE LIKE '%search%'. I have done some searching,
but was never quite sure what to really search for. Is there an easy
way around this or can someone point me in the right direction? THANKS!

Aug 1 '05 #1
14 1766

"kiqyou_vf" <so*******@gmai l.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Hello all, I'm trying to figure out how to search a "key_words" column,
that contain key words (obviously) for that row. An example of what one
of the key_words contains is: "home interior decorating". I can search
for "home interior" or "interior decorating" and it will return the
correct row, but if I search for "interior home" or "home decorating" I
get nothing. I need it to return any row with ALL of those words in any
order. I am using WHERE LIKE '%search%'. I have done some searching,
but was never quite sure what to really search for. Is there an easy
way around this or can someone point me in the right direction? THANKS!


WHERE key_words like %home% AND key_words like %interior% AND key_words like
%decorating%
Aug 1 '05 #2
One option would be something like this:

If you're searching for (foo) and (bar)

select *
from my_table
where key_words like '%foo%'
and key_words like '%bar%'

Aug 1 '05 #3
I'm sorry, I forgot to mention that the '%search%' is coming from a
form- $_GET['search']

Aug 1 '05 #4
kiqyou_vf wrote:
I'm sorry, I forgot to mention that the '%search%' is coming from a
form- $_GET['search']


You may want to use the explode() function to split the $_GET text into
and array of 'words' first. Then loop through this array of words adding
the '%' chars to the beginning and end of each word while building the
sql statement.

Carl.
Aug 1 '05 #5
On 2005-08-01, kiqyou_vf <so*******@gmai l.com> wrote:
Hello all, I'm trying to figure out how to search a "key_words" column,
that contain key words (obviously) for that row. An example of what one
of the key_words contains is: "home interior decorating". I can search
for "home interior" or "interior decorating" and it will return the
correct row, but if I search for "interior home" or "home decorating" I
get nothing. I need it to return any row with ALL of those words in any
order. I am using WHERE LIKE '%search%'. I have done some searching,
but was never quite sure what to really search for. Is there an easy
way around this or can someone point me in the right direction? THANKS!


Have a look at http://dev.mysql.com/doc/mysql/en/fulltext-search.html
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be >
Aug 1 '05 #6
Damn, I was hoping that it wouldn't be the only way. I looked at that
earlier and couldnt understand anything. Are there any tutorials that
use fulltext search that you know of? I mean, if thats the way I have
to do it, then I'll do it but I was really hoping for a quicker
solution- or a work around. Anyway, thanks for pointing me in the
proper direction.

Aug 1 '05 #7
kiqyou_vf wrote:
Damn, I was hoping that it wouldn't be the only way. I looked at that
earlier and couldnt understand anything. Are there any tutorials that
use fulltext search that you know of? I mean, if thats the way I have
to do it, then I'll do it but I was really hoping for a quicker
solution- or a work around. Anyway, thanks for pointing me in the
proper direction.


Why wouldn't you just use multiple 'anded' tests when pattern matching?

"SELECT * FROM `table` WHERE `description` LIKE '%interior%' AND
`description` LIKE '%home%'"
Carl.
Aug 1 '05 #8
I'm sorry, I guess I don't understand.'%in terior%' and '%home%' need to
come from a query entered into a text box, not a pre-defined link.

Is there a way I could put the multi-word search into an array,
seperated by spaces and make each item in the array print out " LIKE
'%item1+1%' " with a loop? Does that make sense?

Aug 2 '05 #9
$searchTerms = explode(' ', $_GET['search']);
$query = 'select * from my_table where ';

foreach($search Terms as $term)
$query .= "key_word like '%" . $term . "%' and ";

$query = substr($query, 0, -4); //get rid of the last 'and'

Aug 2 '05 #10

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

Similar topics

37
4899
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours, Pujo
4
4677
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
3880
by: * ProteanThread * | last post by:
but depends upon the clique: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den ...
0
3789
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black and white CCITT4 compressed files (frames) inside the tiff. Every now and then I receive a mixture of black and white CCITT4 and JPEG compressed files, and sometimes just multi-page tiffs with JPEG only. The code runs great when dealing with the...
6
8183
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
4
17878
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the problem is the charset? How I can avoid this warning? But the worst thing isn't the warning, but that the program doesn't work! The program execute all other operations well, but it don't print the converted letters: for example, in the string...
5
6000
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a TIFF to several PNG files this causes a problem, becuase the resulting image is (the page to the far left and a lot of black space surrounding it and a filesize that is larger than needed. Any ideas?
5
5768
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone know a good place to start looking for some theory on the subject of multi user applications? I know only bits and pieces, like about transactions, but a compendium of possible approches to multi user programming would be very appreciated!
0
2329
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing Systems (MuCoCoS'08) Barcelona, Spain, March 4 - 7, 2008; in conjunction with CISIS'08. <http://www.par.univie.ac.at/~pllana/mucocos08> *********************************************************************** Context
1
9320
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "PAR.PAR_Status" could not be bound. The multi-part identifier "Salary.New_Salary" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part...
0
10162
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10100
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.