473,587 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

database search

I've a table filed holds keywords seperated by comma, and a web search form
where a user can type one of multiple keywords in the search text field
seperated by comma aswell. How do i create a sql statement to bring results
that matches one or more keywords in the database?

Many thanks in advance..

huzz
Jul 21 '05 #1
3 1566
More of a database question than a .NET question. You may be able to find your answer by posting in a more appropritate group.

Assuming your using SQL Server, check out the IN keyword in T-SQL and the LIKE keyword.

IN lets you group fields together using commas.
LIKE lets you perform wildcard comparisons between strings.

Examples:

SELECT * FROM MyTable WHERE @Search IN (NameField, DescriptionFiel d)
SELECT * FROM MyTable WHERE NameField LIKE @Search + '%'

If your going to search a comma-seperated list of values stored in a single field, you may have to use Dynamic-SQL. There are
examples of how to use this in the SQL Server docs and on the web.

Check out the stored procedure named, ""

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"huzz" <hu**@discussio ns.microsoft.co m> wrote in message news:57******** *************** ***********@mic rosoft.com...
I've a table filed holds keywords seperated by comma, and a web search form
where a user can type one of multiple keywords in the search text field
seperated by comma aswell. How do i create a sql statement to bring results
that matches one or more keywords in the database?

Many thanks in advance..

huzz

Jul 21 '05 #2
If you are storing in a garbage dump (table with lots of text,
non-separated), your best option is using a full text index to index the
comma separated keywords. Personally, I would consider a less taxing
database structure, like one that enumerates the keywords, but that is just
my feeling on this type of data. It may not be feasible in your situation.

Regardless of your choice, the user's list of keywords presents you with
options:

1. Write the SQL in your app and submit to the database
2. Turn the keyword list into XML and use the XML capabilities of the
database (both Oracle and SQL Server can use this option)
3. Create a stored procedure that puts the user list in a temp table and
join that table with the tables being queried

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** **
Think outside the box!
*************** *************** *************** **
"huzz" <hu**@discussio ns.microsoft.co m> wrote in message
news:57******** *************** ***********@mic rosoft.com...
I've a table filed holds keywords seperated by comma, and a web search
form
where a user can type one of multiple keywords in the search text field
seperated by comma aswell. How do i create a sql statement to bring
results
that matches one or more keywords in the database?

Many thanks in advance..

huzz

Jul 21 '05 #3
Sorry, I submitted the post prematurely :)

Check out the stored proc named, "sp_executesql" . There is a performance cost when using this approach.

Also check out the FullText search capabilities for an alternative method of searching for keywords in Sql Server.

I recommend just bringing down the data to your code, and checking the keywords there, if possible.
Good Luck

--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"huzz" <hu**@discussio ns.microsoft.co m> wrote in message news:57******** *************** ***********@mic rosoft.com...
I've a table filed holds keywords seperated by comma, and a web search form
where a user can type one of multiple keywords in the search text field
seperated by comma aswell. How do i create a sql statement to bring results
that matches one or more keywords in the database?

Many thanks in advance..

huzz

Jul 21 '05 #4

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

Similar topics

6
1702
by: Alexandre Plennevaux | last post by:
hello mates, my question is such: should i turn a 80 pages doc file into a database so that: - i can make it searchable through an online form - it can be modified and every modification archives the previous version, inside an "archive" table. ??
0
5586
by: Rob Young | last post by:
This is the latest in the "Total Non-Programmer" series. Any feedback on the usability of this tutorial would be greatly appreciated. Thanks, Rob How to Build A Web Database (Without Programming) This article will teach you step-by-step how to add interactive database-driven capabilities to your existing web site. When the steps
4
1900
by: visionstate | last post by:
Hi there, I'm fairly new to access and the way it works and I have been building a relatively simple database. It is basically a database where staff members can search for what training they (or others) have completed by staff name, staff group or training name. I created this using a form which had 2 text boxes and a combo box. These were...
3
2930
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news groups for years, I figure it's time for me to contribute a little bit back, maybe some people out there will find this useful. * Introduction ...
3
2770
by: vonclausowitz | last post by:
Hi All, I was thinking of creating a table in my database to index all words in the database. That way I can quickly search for one or more words and the index table will return the words and records I need. For example the iTable would look like this:
5
2686
by: Mark | last post by:
Hi I have an application (in vb.NET 2005) which holds data in SQL Server and some of the SQL records are simply paths to related files. I would like to be able to do a text search on both the SQL data and the contents of any referenced files. The returned list being a listing which includes both records containing the text and files...
7
11774
by: ianenis.tiryaki | last post by:
well i got this assignment which i dont even have a clue what i am supposed to do. it is about reading me data from the file and load them into a parallel array here is the question: Step (1) Your first task is to write a program which reads this file into two parallel arrays in memory. One array contains the titles, and the other array...
1
7523
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and having the sql statement dynamically built according to the input provided by the user. I have used the method described here hundreds of times it is...
13
1379
by: Jonathan Wood | last post by:
I'd like to build a Website that contains many articles. Two basic approaches are to either store the articles in aspx files, possibly indexed by the database, or to store the article text in the database. Some advantages of storing them in files are simplicity, and efficiency. Some advantages of storing them in the database are ease of...
25
2784
by: pereges | last post by:
Hello, I'm trying to build a database driven website for a library management system. The database is stored on a remote server which all of my team mates can access. I've installed MySQL, PHP and Apache on my machine. I'm a beginner and I really don't understand how to proceed. My biggest problem is how to connect to the database on remote...
0
7918
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...
0
8206
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8220
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...
0
6621
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...
1
5713
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...
0
5392
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...
0
3840
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...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.