Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / July 2006



Tip: Looking for answers? Try searching our database.

best way to search for multiple words through a query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vonclausowitz@gmail.com - 28 Jul 2006 17:02 GMT
Hi All,

I'm looking for a way to search for multiple words in a database.
There is however one but. The words have to be within a certain range
of each other.

For example I would like to find records which contain the word MALE
and within for example 10 words of it the word BROWN.

My idea is to run a query finding the word MALE, and then with these
records go and search for the word BROWN using Instr,

but maybe there is an even easier way.

Marco
KwikOne - 29 Jul 2006 15:21 GMT
> Hi All,
>
[quoted text clipped - 11 lines]
>
> Marco

Marco,
Depending upon your database (MS Access, MSSQL, MySQL, Oracle, etc.)
would depend upon the specifics. However, what it sounds like is that
you want to do a query of a subquery such as SELECT * FROM (SELECT *
FROM Table WHERE Field LIKE `%MALE%`) WHERE Field LIKE ` BROWN ` LIMIT
10
The example syntax will NOT work for all of the database types but
should give you the idea of what to do. This looks for a word BROWN (as
delimited by spaces - for other begin/end delimiters you would need to
add in some OR's) within the query where the pattern of MALE (which
will also match FEMALE or MALE or MALE. or MALE; etc.) and limits the
result to 10 records.

Kerry
vonclausowitz@gmail.com - 29 Jul 2006 16:24 GMT
Hi,

I'm using an access database.
I don't want to limit the result to 10 records but I want to search for
words NEAR.
So word Y within 10 words of word X.

Marco

KwikOne schreef:

> > Hi All,
> >
[quoted text clipped - 26 lines]
>
> Kerry
Steve Gerrard - 29 Jul 2006 21:40 GMT
> Hi,
>
[quoted text clipped - 4 lines]
>
> Marco

Access doesn't have full text searching. Even in Oracle, you have to setup a
special text index and such in order to do proximity searches using CONTAINS and
NEAR.

I would at least make your initial query find records that contain both words,
regardless of separation, using something such as
   WHERE (((Test.MemoField) Like "*BROWN*" And (Test.MemoField) Like
"*MALE*"));

If you are interested in word separation, not just number of characters, you
would then need to split the text of each record into words, then loop through
the words to see if the two are within 10 of each other.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.