473,508 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

syntax question whole word finding


Is there a way to construct a query to select for whole words only?

select id from bookdata where titles like '%Test%' gets everything with
test somewhere in the field. So you could get records which have test
as a subset of a larger word like 'testing' etc...

What I am interested in is finding just the individual words in a
stored field.

Say a field has 'Test your knowledge on this one.' and you want to find
'Test' or 'knowledge' the word, not test or knowledge as parts of
others words etc...anywhere and everywhere in the field and involving
many records . How can you do this? or can this be done?
Thanks for any help.

Jul 23 '05 #1
5 6584
Sri
If I understand what you are saying correctly then this will be the
query:
Select id from bookdata where titles = 'test'. This qry's result will
be only the rows whose title is test.

Let me know if this is what you wanted.
Thanks
Sri

Jul 23 '05 #2
sd********@msn.com (sd********@msn.com) writes:
Is there a way to construct a query to select for whole words only?

select id from bookdata where titles like '%Test%' gets everything with
test somewhere in the field. So you could get records which have test
as a subset of a larger word like 'testing' etc...

What I am interested in is finding just the individual words in a
stored field.

Say a field has 'Test your knowledge on this one.' and you want to find
'Test' or 'knowledge' the word, not test or knowledge as parts of
others words etc...anywhere and everywhere in the field and involving
many records . How can you do this? or can this be done?


To do this reliably in regular SQL is difficult. However, SQL Server
comes with a full-text capability, which I think could be useful here.
I have very little experience with full-text myself, but you can read
about it in Books Online.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #3
Yes, I think that is what I could use.
Apparently SQlserver can make an index of words contained in the fields
Then you search - select name from bookdata where contains(name,'Word
to find')

Anyway you have to build the index before you search it. I am
interested in trying this out.
Does anyone know the syntax for creating a fulltext index?

Jul 23 '05 #4
sd********@msn.com (sd********@msn.com) writes:
Yes, I think that is what I could use.
Apparently SQlserver can make an index of words contained in the fields
Then you search - select name from bookdata where contains(name,'Word
to find')

Anyway you have to build the index before you search it. I am
interested in trying this out.
Does anyone know the syntax for creating a fulltext index?


As I said, I don't use full-text myself, but I were to look into it,
I would find the relevant sections in Books Online to study. Books Online
is by no means intended for the experts, so why don't you try the same?

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #5
'Test your knowledge on this one.'

try 'Test %' -- NOTE: the *space* before the %
should find 'Test your knowledge on this one.'
but not 'Testing your knowledge on this one.'

try 'Test%' -- NOTE: *no* space before the %
should find 'Test your knowledge on this one.'
and 'Testing your knowledge on this one.'
try '% Test %' -- NOTE: the spaces before and after the %
should find 'Need to Test your knowledge on this one.'
but not 'Test your knowledge on this one.'

where field LIKE '% Test %' OR field LIKE 'Test %' OR field LIKE '% Test'
should catch 'test' anywhere in a string
'test aaa bbb' or 'aaa test bbb' or 'aaa bbb test'

For simple cases this type of stuff can save on the overheads of full text
indexing (and managing the re-indexing of it)

Julian 8^)

<sd********@msn.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...

Is there a way to construct a query to select for whole words only?

select id from bookdata where titles like '%Test%' gets everything with
test somewhere in the field. So you could get records which have test
as a subset of a larger word like 'testing' etc...

What I am interested in is finding just the individual words in a
stored field.

Say a field has 'Test your knowledge on this one.' and you want to find
'Test' or 'knowledge' the word, not test or knowledge as parts of
others words etc...anywhere and everywhere in the field and involving
many records . How can you do this? or can this be done?
Thanks for any help.

Jul 23 '05 #6

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

Similar topics

6
1940
by: Aaron | last post by:
If i use the replace function in c# string a = "this"; a.replace("is", "something"); my output would be like thsomething how can i replace when only the whole word matches. string a =...
3
1727
by: Giles | last post by:
Is there a way to get records containing a whole word? I've heard regular expressions can do it, but I can't make one work in an ASP / MS Access SQL Query sSQL="SELECT PageTitle FROM Pages WHERE...
4
3587
by: shonend | last post by:
I am trying to extract the pattern like this : "SUB: some text LOT: one-word" Described, "SUB" and "LOT" are key words; I want those words, everything in between and one word following the...
4
4782
by: seannakasone | last post by:
Is there a way to search a string for a whole word w/o using a regular expression? i.e. mystring.IndexOf(mypattern, *WholeWord); The reason i rather not use a regular expression is because...
1
1404
by: Buddhist[CHinA] | last post by:
I mean I wanna search a string in certain text files. But I don't know how to effectively get a whole-word match result. Can someone do me a favor? thx.
1
9027
by: Michael Yanowitz | last post by:
Hello: I am hoping someone knows if there is an easier way to do this or someone already implemented something that does this, rather than reinventing the wheel: I have been using the...
2
1415
by: summersurfer25 | last post by:
Hello, I am new with C# but have experienced in other similar languages such as Java. What I am trying to do is search a long .l5k file for any time a line begins with "f_". Once I find this...
17
2114
by: denakaraj | last post by:
Hi All, i am new to VB. below is the scenario I am having 2 Textboxes say Text1 and Text2 i need to find the Text2.text in the Text1 with whole word constraint i would like to get coding for...
3
4319
by: Tre MoR | last post by:
Regular Expression: how match a whole word? Hi All, First of all, I’d express all my gratitude to all whom will help me about this topic. I have a question about the Regular Expression Engine,...
0
7115
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
7321
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,...
1
7036
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
7489
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...
1
5047
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...
0
4705
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...
0
3191
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.