473,396 Members | 2,139 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,396 software developers and data experts.

Search using multiple keywords

Howdy,

I am doing a simple keyword search in my SQL database from my ASP.NET w/ VB
application. Currently, I am using a PROC and within the PROC I am doing
something like so:

SELECT * FROM tblStores WHERE strName LIKE '%' + @Search + '%' AND strCity
LIKE '%' + @Search + '%' and so on

This works GREAT for a single keyword like marshalls. However, if the user
enters in 'marshalls ma' nothing returns and I understand why.

How do I split this string in the PROC and then use each piece to search
against? Is there a better way than I am thinking?

Thank you!!

David Lozzi
Nov 19 '05 #1
2 1549
David Lozzi wrote:
Howdy,

I am doing a simple keyword search in my SQL database from my ASP.NET w/ VB
application. Currently, I am using a PROC and within the PROC I am doing
something like so:

SELECT * FROM tblStores WHERE strName LIKE '%' + @Search + '%' AND strCity
LIKE '%' + @Search + '%' and so on

This works GREAT for a single keyword like marshalls. However, if the user
enters in 'marshalls ma' nothing returns and I understand why.

How do I split this string in the PROC and then use each piece to search
against? Is there a better way than I am thinking?

Thank you!!

David Lozzi

Your code must separate the words into a CSV string.

Easy example:

mySearchString = mySearchString.Replace(" ","%,%")

then:

SELECT *
FROM tblStores
WHERE strName IN@Search
UNION
SELECT *
FROM tblStores
WHERE strCity IN @Search

That way you can get results if the search is in one clumn and not the
other.

/RT
Nov 19 '05 #2
This kind of works. For example:

SELECT * FROM tblStores WHERE strState IN ('ma','nh')

works, but if I do this

SELECT * FROM tblStores WHERE strState IN ('%m%','%n%')

Nothing returns. It doesn't appear to suppose wild cards?

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

"Ryan Ternier" <rt******@icompasstech.com> wrote in message
news:OF**************@TK2MSFTNGP10.phx.gbl...
David Lozzi wrote:
Howdy,

I am doing a simple keyword search in my SQL database from my ASP.NET w/
VB application. Currently, I am using a PROC and within the PROC I am
doing something like so:

SELECT * FROM tblStores WHERE strName LIKE '%' + @Search + '%' AND
strCity LIKE '%' + @Search + '%' and so on

This works GREAT for a single keyword like marshalls. However, if the
user enters in 'marshalls ma' nothing returns and I understand why.

How do I split this string in the PROC and then use each piece to search
against? Is there a better way than I am thinking?

Thank you!!

David Lozzi

Your code must separate the words into a CSV string.

Easy example:

mySearchString = mySearchString.Replace(" ","%,%")

then:

SELECT *
FROM tblStores
WHERE strName IN@Search
UNION
SELECT *
FROM tblStores
WHERE strCity IN @Search

That way you can get results if the search is in one clumn and not the
other.

/RT

Nov 19 '05 #3

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

Similar topics

3
by: huzz | last post by:
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...
83
by: D. Dante Lorenso | last post by:
Trying to use the 'search' in the docs section of PostgreSQL.org is extremely SLOW. Considering this is a website for a database and databases are supposed to be good for indexing content, I'd...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
5
by: JP SIngh | last post by:
Hi All This is a complicated one, not for the faint hearted :) :) :) Please help if you can how to achieve this search. We have a freetext search entry box to allow users to search the...
3
by: Richard S | last post by:
CODE: ASP.NET with C# DATABASE: ACCES alright, im having a problem, probably a small thing, but i cant figure out, nor find it in any other post, or on the internet realy (probably cuz i wouldnt...
5
by: mforema | last post by:
Hi Everyone, I want to search records by typing in multiple keywords. I currently have a search form. It has a combo box, text box, Search command button, and a subform. The combo box lists the...
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...
0
by: Bob Alston | last post by:
I am doing volunteer work with a human services referral agency. The want me to build a database of referral data - other agencies, sources of information, etc. Ideally it would be a structured...
0
by: Skywick | last post by:
Hi I am trying to do a full text search with a column name for the search term. I can do this using LIKE with: SELECT tblContent.ID FROM tblContent INNER JOIN #keywords ON tblContent.words...
18
by: luke noob | last post by:
can some one please help me adapt my script so that i can search for multiple words within my database, my keywords feild looks something like this.... Big Teddie Bear Collection Tiny Small...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
0
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...
0
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,...

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.