Solved

Search by any word!

Posted on 1998-07-20
2
202 Views
Last Modified: 2010-03-19
I want to know how to write the SQLQuery that it can search in the table by any word!
0
Comment
Question by:ruisun
2 Comments
 
LVL 2

Accepted Solution

by:
odessa earned 50 total points
ID: 1091801
very dificult question if you want to search whole table for a word (for example "KILE") do some like this:
select * from TABLE
where
(FILED1 like "%KILE%") or
(FILED2 like "%KILE%") or
(FILED3 like "%KILE%") ...


. some like this this is the only way
0
 
LVL 1

Expert Comment

by:mativare
ID: 1091802
In MSSQL server 7.0 beta you can use full text indexing with
Contains
Contains is powerful keyword
This example searches for all products with words of the form "dry": dried, drying, and so on.
(See if you use like dry* over here, it is another story and it returns lot of garbage too)
USE Northwind
GO
SELECT ProductName
FROM Products
WHERE CONTAINS(ProductName, ' FORMSOF (INFLECTIONAL, dry) ')
GO
I cannot do it with 'like'
also it can use Near() function, wich searches word next to given word
[WHERE CONTAINS(ProductName, 'spread NEAR () Boysenberry']
also uses weighted terms
WHERE CONTAINS(Description, 'ISABOUT (spread weight (.8),
    sauces weight (.4), relishes weight (.2) )' )
See it is simple and powerful, it scrolls every row but
with full text indexing it allows to do sophisticated searches fast, before it was possible only in DB2 and Oracle.
I cannot see we can replace all this examples with LIKE
More in MSSQL 7.0 beta Books Online


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question