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

Keyword Search Help

I currently am looking for a solution to solve a 'keyword search' problem. I am using the 'like' functionality to retrieve the values that match the keyword that is entered. However, how can I make the search a multiple keyword search using semicolons to seperate the words?? For example: The user should be able to enter 'admin; manager; director;'.

Any input would be greatly appreciated. Thanks

Here is my stored procedure:


create procedure procSearch

@TrainingCertification varchar(50) = null

as
begin

select *
from TrainingCertifications
where TrainingCertificationsType LIKE '%' + @TrainingCertification + '%'

end;
Sep 21 '06 #1
8 7396
I am a newbie..but what I guess is:
try to do this in 2 procedures instead of one. The inner procedure should find out all key words by slicing the userinput with the delimiter like ';' and the outer procedure then takes each of this slice to do the search..
Sep 24 '06 #2
Meme
1
you need to use code to break up what they enter into the textbox into different variables, which you then use either - use individually in one repeatedl stored procedure. Or, use in a single stored procedure with many parameters.

e.g. code something a bit like ...

string mySearchTerm = txbSearch.Text;
string myParameter = mySearchTerm.Substring(mySearchTerm.IndexOf(";"), mySearchTerm.IndexOf(" "));

then call your stored procedure.

Hoep that helps.
Oct 30 '06 #3
you need to use code to break up what they enter into the textbox into different variables, which you then use either - use individually in one repeatedl stored procedure. Or, use in a single stored procedure with many parameters.

e.g. code something a bit like ...

string mySearchTerm = txbSearch.Text;
string myParameter = mySearchTerm.Substring(mySearchTerm.IndexOf(";"), mySearchTerm.IndexOf(" "));

then call your stored procedure.

Hoep that helps.
altough it aint my thread, id like to thank you alot for this! helped me out alot! ty man
Apr 12 '07 #4
sayedul
12
Hi,

You can make a sql function with a parameter string to return a table with all the semicolon separate words as in different records. Use the function in the stored procedure. Use cursor to get different words from the table returned by the function within the stored procedure. Use the select statement for different words in cursor loop to fill a temporary table. Finally return the temporary table records. This should serve your requirement. You can ask me for the detailed script if you still cannot prepare the script.

Thanks.

Sayedul


I currently am looking for a solution to solve a 'keyword search' problem. I am using the 'like' functionality to retrieve the values that match the keyword that is entered. However, how can I make the search a multiple keyword search using semicolons to seperate the words?? For example: The user should be able to enter 'admin; manager; director;'.

Any input would be greatly appreciated. Thanks

Here is my stored procedure:


create procedure procSearch

@TrainingCertification varchar(50) = null

as
begin

select *
from TrainingCertifications
where TrainingCertificationsType LIKE '%' + @TrainingCertification + '%'

end;
Oct 8 '07 #5
iburyak
1,017 Expert 512MB
If you are interested in database solution try this:

1. create function on database side.

[PHP]CREATE FUNCTION Split(@String nvarchar(4000), @Delimiter char(1))
RETURNS @Results TABLE (ID int, Items nvarchar(4000))
AS

BEGIN
DECLARE @INDEX INT
DECLARE @SLICE nvarchar(4000)
DECLARE @ID int

SELECT @INDEX = 1, @ID = 1
WHILE @INDEX !=0


BEGIN
-- GET THE INDEX OF THE FIRST OCCURENCE OF THE SPLIT CHARACTER
SELECT @INDEX = CHARINDEX(@Delimiter,@STRING)
-- NOW PUSH EVERYTHING TO THE LEFT OF IT INTO THE SLICE VARIABLE
IF @INDEX !=0
SELECT @SLICE = LEFT(@STRING,@INDEX - 1)
ELSE
SELECT @SLICE = @STRING
-- PUT THE ITEM INTO THE RESULTS SET
INSERT INTO @Results(ID, Items) VALUES(@ID, @SLICE)
SELECT @ID = @ID + 1
-- CHOP THE ITEM REMOVED OFF THE MAIN STRING
SELECT @STRING = RIGHT(@STRING,LEN(@STRING) - @INDEX)
-- BREAK OUT IF WE ARE DONE
IF LEN(@STRING) = 0 BREAK
END
RETURN
END
[/PHP]

2. Create procedure.

[PHP]create procedure procSearch

@TrainingCertification varchar(50) = null

as
begin

select *
from TrainingCertifications
join Split(@TrainingCertification, ';') on charindex(items, LTRIM(RTRIM(TrainingCertificationsType))) > 0

end[/PHP]


I can't test this code but I tested on my database with my tables and it worked.

Good Luck.
Oct 8 '07 #6
sayedul
12
Hi,

The detail of the DB solution is greate especially the select statement written in the stored procedure.

Thanks.

If you are interested in database solution try this:

1. create function on database side.

[PHP]CREATE FUNCTION Split(@String nvarchar(4000), @Delimiter char(1))
RETURNS @Results TABLE (ID int, Items nvarchar(4000))
AS

BEGIN
DECLARE @INDEX INT
DECLARE @SLICE nvarchar(4000)
DECLARE @ID int

SELECT @INDEX = 1, @ID = 1
WHILE @INDEX !=0


BEGIN
-- GET THE INDEX OF THE FIRST OCCURENCE OF THE SPLIT CHARACTER
SELECT @INDEX = CHARINDEX(@Delimiter,@STRING)
-- NOW PUSH EVERYTHING TO THE LEFT OF IT INTO THE SLICE VARIABLE
IF @INDEX !=0
SELECT @SLICE = LEFT(@STRING,@INDEX - 1)
ELSE
SELECT @SLICE = @STRING
-- PUT THE ITEM INTO THE RESULTS SET
INSERT INTO @Results(ID, Items) VALUES(@ID, @SLICE)
SELECT @ID = @ID + 1
-- CHOP THE ITEM REMOVED OFF THE MAIN STRING
SELECT @STRING = RIGHT(@STRING,LEN(@STRING) - @INDEX)
-- BREAK OUT IF WE ARE DONE
IF LEN(@STRING) = 0 BREAK
END
RETURN
END
[/PHP]

2. Create procedure.

[PHP]create procedure procSearch

@TrainingCertification varchar(50) = null

as
begin

select *
from TrainingCertifications
join Split(@TrainingCertification, ';') on charindex(items, LTRIM(RTRIM(TrainingCertificationsType))) > 0

end[/PHP]


I can't test this code but I tested on my database with my tables and it worked.

Good Luck.
Oct 25 '07 #7
I am a newbie..but what I guess is:
try to do this in 2 procedures instead of one. The inner procedure should find out all key words by slicing the userinput with the delimiter like ';' and the outer procedure then takes each of this slice to do the search..


Hi

Create FULL TEXT CATALOG in Sql Server. Search how to create Catalog in online or Sql Server Books online help. Its very easy to find keyword search help. Its ack like small search engine. It creating character based index in DataBase. When you type keyword and search it will shows your required search

way to create full text catalog:
1. Expand a server group, and then expand a server.
2. Expand Databases, and then right-click the database where you want the full- text catalog.
3. Click New, and then click New Full-Text Catalog.
4. Complete the New Full-Text Catalog dialog box.

You must install your Sql Server in Custom Installation. Then only we create Full Text Catalog. We create Full Text Catalog using Sql queries also. search in sql server book online file (chm file). We create schedule for catalog. Its automatically populated while your database update or set the time interval when ever we want the catalog can be populated.

This is the simple way to create keyword search help
Oct 25 '07 #8
sayedul
12
I currently am looking for a solution to solve a 'keyword search' problem. I am using the 'like' functionality to retrieve the values that match the keyword that is entered. However, how can I make the search a multiple keyword search using semicolons to seperate the words?? For example: The user should be able to enter 'admin; manager; director;'.

Any input would be greatly appreciated. Thanks

Here is my stored procedure:


create procedure procSearch

@TrainingCertification varchar(50) = null

as
begin

select *
from TrainingCertifications
where TrainingCertificationsType LIKE '%' + @TrainingCertification + '%'

end;

Hi,

I have written another very simple solution of the problem. The solution is tested. The procedure is as follows:

Expand|Select|Wrap|Line Numbers
  1. create procedure procSearch
  2. @TrainingCertification varchar(50) = null
  3. as
  4. begin
  5. select *
  6. from TrainingCertifications
  7. where (';' + replace(@TrainingCertification, '; ', ';') + ';') 
  8. like ('%;' + TrainingCertificationsType + ';%')
  9. end
  10.  

- Sayedul Haque
Nov 7 '07 #9

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

Similar topics

10
by: Jacek Generowicz | last post by:
Where can I find concise, clear documentation describing what one has to do in order to enable Python's internal help to be able to provide descriptions of Python keywords ? I am in a situation...
2
by: Torfi Sackbatten | last post by:
Hi Everyone, I´m asked to "speed up" a keyword search based on MySQL. The material i´m given to work with is a quite large MySQL table with 1.5 mio rows, defined something like: CREATE TABLE...
4
by: Axel | last post by:
Is it possible to write a Stored Procedure that takes a string of search keywords as argument and returns the recordset? At the mo I am passing the WHERE String as argument. I got this...
4
by: geetha | last post by:
Dear all, I have a database with all the research capabilities of professors of a university. I need to implement a "keyword search" feature in my welcome page which will actually work like a...
2
by: rlemusic | last post by:
Hi everybody, I’m creating a database in Access (I believe it’s 2000) to catalogue items in the archives of a small museum. I’m a total n00b as far as using Access goes, but by looking at some...
3
by: Redbeard | last post by:
Hi All this is my first time post, be gentle. I am looking at creating a keyword search that searches multiple fields in a Form and then filters records that match the keyword. The Form...
5
by: kanley | last post by:
I have a main table with a text description field. In this field, its populated with a string of data. I need to identify from this string of data the name of the vendor using some keywords. I...
1
by: prasath03 | last post by:
Hi Gurus, I am doing one website project that project contains one search module. In that search page i have entered the keyword to search. If i want to search the keyword with "any keyword" or...
1
adelemb
by: adelemb | last post by:
Hi, I'm trying to make a SQL statement work and am getting quite mixed up with it, I hope someone can help! I have a form with a textbox named "keyword". I want the user to enter a keyword and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...

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.