473,787 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Keyword Search Help

1 New Member
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

@TrainingCertif ication varchar(50) = null

as
begin

select *
from TrainingCertifi cations
where TrainingCertifi cationsType LIKE '%' + @TrainingCertif ication + '%'

end;
Sep 21 '06 #1
8 7416
shreyaas
3 New Member
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 New Member
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.Su bstring(mySearc hTerm.IndexOf(" ;"), mySearchTerm.In dexOf(" "));

then call your stored procedure.

Hoep that helps.
Oct 30 '06 #3
Richard S
9 New Member
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.Su bstring(mySearc hTerm.IndexOf(" ;"), mySearchTerm.In dexOf(" "));

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 New Member
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

@TrainingCertif ication varchar(50) = null

as
begin

select *
from TrainingCertifi cations
where TrainingCertifi cationsType LIKE '%' + @TrainingCertif ication + '%'

end;
Oct 8 '07 #5
iburyak
1,017 Recognized Expert Top Contributor
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(@Deli miter,@STRING)
-- NOW PUSH EVERYTHING TO THE LEFT OF IT INTO THE SLICE VARIABLE
IF @INDEX !=0
SELECT @SLICE = LEFT(@STRING,@I NDEX - 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,L EN(@STRING) - @INDEX)
-- BREAK OUT IF WE ARE DONE
IF LEN(@STRING) = 0 BREAK
END
RETURN
END
[/PHP]

2. Create procedure.

[PHP]create procedure procSearch

@TrainingCertif ication varchar(50) = null

as
begin

select *
from TrainingCertifi cations
join Split(@Training Certification, ';') on charindex(items , LTRIM(RTRIM(Tra iningCertificat ionsType))) > 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 New Member
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(@Deli miter,@STRING)
-- NOW PUSH EVERYTHING TO THE LEFT OF IT INTO THE SLICE VARIABLE
IF @INDEX !=0
SELECT @SLICE = LEFT(@STRING,@I NDEX - 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,L EN(@STRING) - @INDEX)
-- BREAK OUT IF WE ARE DONE
IF LEN(@STRING) = 0 BREAK
END
RETURN
END
[/PHP]

2. Create procedure.

[PHP]create procedure procSearch

@TrainingCertif ication varchar(50) = null

as
begin

select *
from TrainingCertifi cations
join Split(@Training Certification, ';') on charindex(items , LTRIM(RTRIM(Tra iningCertificat ionsType))) > 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
karthickbabu
33 New Member
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 New Member
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

@TrainingCertif ication varchar(50) = null

as
begin

select *
from TrainingCertifi cations
where TrainingCertifi cationsType LIKE '%' + @TrainingCertif ication + '%'

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
2281
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 where I have to give Python novices the ability to fix this for themselves easily. Failing "concise" and "clear", how about "complete and correct" ?
2
2727
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 datarecords ( id BIGINT(20) NOT NULL auto_increment, , keywords TEXT NOT NULL,
4
9680
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 technique from an Extreme Ultradev tutorial by Rick Curtis it looked quite ok: http://www.princeton.edu/~rcurtis/ultradev/tutorial12.html I have to admit, one of the main reason for passing the WHERE string is that I do not know how to do the string...
4
1580
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 query generator and search my entire database for the keyword entered by the user and show up table/form that has the keyword searched for. Please let me know as soon as possible.
2
2674
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 online tutorials and how the museum’s existing collections catalogue is set up in Access, I’ve been able to come up with a basic database that suits the museum’s needs. My biggest issues right now concern Relationships and Codes. I managed to get a...
3
5402
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 currently has a button that connects to a Query that run the keyword search in several field and then filters the results. The problem is that I can not do a search within a search, or have multiple words searched in any order. For example there are 20,000...
5
3381
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 have another table that contains 2 fields, one being the keywords to search for from the string of data and the other field being the vendor name to pair up with the record. How do I reference the keywords from the 2nd table and search thru the...
1
3140
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 "all keyword" after searched the records are showed. what i expecting is i want to hightlight the all keyword in that page with case insensitive. I am doing that concept in jsp page and sql server. example for any keyword: internal medicine ...
1
3865
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 then a search occurs through the table to find that keyword. The results should then be displayed on the next page. I have the keyword parameter appearing in the page URL e.g. www.xxxxxx.com/page.htm?keyword=help My problem (I think) is the way I...
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10172
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3670
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.