473,320 Members | 1,979 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,320 software developers and data experts.

finding multiple keywords in aparticular string

hi all,

plz help me out, is there any function or wayout to find multiple keywords from a perticular string stored in the database.

e.g

String stored in database: "hi my name is sachin"
key words to find: "sachin","hi" "is"

i want something like this

search(source string,"keyword1" or "keyword2" or keyword3")


if anyone have implemented this can u plz let me know
May 22 '07 #1
3 2148
frozenmist
179 Expert 100+
Hi Sachin,
Why dont you think of doing it with LIKE operator as in:

Select 1 from <table> where string like '%hi%' or string like '%sachin%'.

Wouldnt this be effective?

Hope this helped you
Cheers
May 22 '07 #2
it will work for or butif want to do the same thing using AND instead of OR then each time it has to do the comparision
is there any effective solution for AND
May 23 '07 #3
chandu031
78 Expert
it will work for or butif want to do the same thing using AND instead of OR then each time it has to do the comparision
is there any effective solution for AND
Hi,

One way of implementing that feature is to write a custom function which will may be accept one parameter as a delimited string containing all the keywords and the
other parameter as the source string and you can use INSTR function in a loop.
Ofcourse this will be fairly simple and ineffecient way of doing it.

Coming to the LIKE operator , it will work fine but you will have to consider three different cases for three different positions of the keyword.
1) If it is the first word of the source string, you will have to use 'hi%'
2) If it is in the middle of the source string, you will have to use '%hi%'
3) If it is the last word of the source string, you will have to use '%hi'

And also since you are searching for words , you might have to use '% hi %'
as you also have a 'hi' in a 'while'. Of course you dont have to do this if you append spaces at the beginning and end of the source string.Looking at all the different possibilities, it is better off to write a custom function,even if has a little overhead.

A better solution anyone?
May 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Noam Dekers | last post by:
Hi all, I would like to find a word stored in a text file. Structure: I have one file named keyWords.txt that stores some key words I'm interested in finding. In addition I also have a file...
4
by: Nel | last post by:
Hi all, Before I re-invent the wheel here, has anyone willing to share a basic script to extract META keywords from a string. I have a string, let's say $pageText that contains the dynamic...
1
by: Tristan | last post by:
Im trying to expand a search util by uing regular expression to allow common search criteria such as +-* and phrases "". My understanding of ereg(string pattern, string string, ) is that the...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
5
by: JP SIngh | last post by:
Hi All This is a complicated one, not for the faint hearted :) :) :) Please help if you can how to achieve this search. We have a freetext search entry box to allow users to search the...
2
by: ElkGroveR | last post by:
Hi there! I'm using PHP to create a simple, dynamic MySQL SELECT query. The user chooses a selection from a HTML Form SELECT element's many options and submits the form via a POST action. ...
3
by: Richard S | last post by:
CODE: ASP.NET with C# DATABASE: ACCES alright, im having a problem, probably a small thing, but i cant figure out, nor find it in any other post, or on the internet realy (probably cuz i wouldnt...
5
by: mforema | last post by:
Hi Everyone, I want to search records by typing in multiple keywords. I currently have a search form. It has a combo box, text box, Search command button, and a subform. The combo box lists the...
1
by: Redbeard | last post by:
I am a newbie running Access 2003. A couple of weeks back a member named ADezil help me write a code that let a , MultiSelect Listboxs that run a Query on a Form (many thanks). I have used this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.