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

Build a search query based on multiple userinput from textboxes

Hi All

I have a search webpage with 10 textboxes, like customerid,
customername, costcenter, business, zipcode , etc.
Now the user can enter any of the values or all of the values or none
of the values and click Search.
Now the 10 textboxes data lie in different tables and each have a
foreign key of CustomerID. So CustomerID is the common data in all the
tables containing zipcode or business, costcenter.

How do i write a stored procedure that would go out to the db and
query the different tables and bring out the matching row for that
combination.
Oct 30 '08 #1
6 4283
On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), th*********@gmail.com wrote:
>Hi All

I have a search webpage with 10 textboxes, like customerid,
customername, costcenter, business, zipcode , etc.
Now the user can enter any of the values or all of the values or none
of the values and click Search.
Now the 10 textboxes data lie in different tables and each have a
foreign key of CustomerID. So CustomerID is the common data in all the
tables containing zipcode or business, costcenter.

How do i write a stored procedure that would go out to the db and
query the different tables and bring out the matching row for that
combination.
Hi thetaamommy,

First, I question the database design. If all these attributes are
functionally dependant on customer, then why don't you combined them in
a single table?

Second, for the answer to your question read this excellent article:
http://www.sommarskog.se/dyn-search.html

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Oct 30 '08 #2
On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), th*********@gmail.com wrote:
>Hi All

I have a search webpage with 10 textboxes, like customerid,
customername, costcenter, business, zipcode , etc.
Now the user can enter any of the values or all of the values or none
of the values and click Search.
Now the 10 textboxes data lie in different tables and each have a
foreign key of CustomerID. So CustomerID is the common data in all the
tables containing zipcode or business, costcenter.

How do i write a stored procedure that would go out to the db and
query the different tables and bring out the matching row for that
combination.
Hi thetaamommy,

Please don't post seperate copies of the same question to multiple
groups. This can lead to fragmented discussion and/or to several people
spending time on a question that has already been answered. Either post
to a single group, or if you really must post to several groups, use a
single, crossposted message.

Ansered in comp.databases.ms-sqlserver

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Oct 30 '08 #3
On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), th*********@gmail.com wrote:
>Hi All

I have a search webpage with 10 textboxes, like customerid,
customername, costcenter, business, zipcode , etc.
Now the user can enter any of the values or all of the values or none
of the values and click Search.
Now the 10 textboxes data lie in different tables and each have a
foreign key of CustomerID. So CustomerID is the common data in all the
tables containing zipcode or business, costcenter.

How do i write a stored procedure that would go out to the db and
query the different tables and bring out the matching row for that
combination.
Hi thetaamommy,

Please don't post seperate copies of the same question to multiple
groups. This can lead to fragmented discussion and/or to several people
spending time on a question that has already been answered. Either post
to a single group, or if you really must post to several groups, use a
single, crossposted message.

Ansered in comp.databases.ms-sqlserver

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Oct 30 '08 #4
On Thu, 30 Oct 2008 21:08:13 +0100, Hugo Kornelis wrote:
>Hi thetaamommy,

Please don't post seperate copies of the same question to multiple
groups. This can lead to fragmented discussion and/or to several people
spending time on a question that has already been answered. Either post
to a single group, or if you really must post to several groups, use a
single, crossposted message.

Ansered in comp.databases.ms-sqlserver
Sorry about that. Somehow, I missed that this *WAS* actually
crossposted. I also missed the follow-up, so the replies intended for
the two other groups ended up here as well.

I'll now post replies in the other groups, to prevent people from
thinking this question is still unanswered.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Oct 30 '08 #5
Dom
On Oct 30, 4:06*pm, Hugo Kornelis
<h...@perFact.REMOVETHIS.info.INVALIDwrote:
On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), thetaamo...@gmail.com wrote:
Hi All
I have a search webpage with 10 textboxes, like customerid,
customername, costcenter, business, zipcode , etc.
Now the user can enter any of the values or all of the values or none
of the values and click Search.
Now the 10 textboxes data lie in different tables and each have a
foreign key of CustomerID. So CustomerID is the common data in all the
tables containing zipcode or business, costcenter.
How do i write a stored procedure that would go out to the db and
query the different tables and bring out the matching row for that
combination.

Hi thetaamommy,

First, I question the database design. If all these attributes are
functionally dependant on customer, then why don't you combined them in
a single table?
This is OT, but I assume that it's a question of one to many joins.
For example, a single person might have multiple cost centers, so the
cost centers are in a different table.

Or am I missing something?

Dom
Oct 31 '08 #6
Erland's article is what i needed, exactly

Thank you guys, for pointing me in the right direction !!
- TAAM
Nov 3 '08 #7

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

Similar topics

5
by: AaronV | last post by:
Hello, I'm a webmaster for a college newspaper and I'm implementing an article search. I'm running PHP with a MySQL database to store the weekly stories. Does anyone know of an article that...
3
by: RiceGuy | last post by:
Hi! I'm looking for ideas on what would the best approach to design a search system for a RSS feeds. I will have some 50 RSS feeds (all RSS 2.0 compliant) stored locally on the web server. Now I'm...
1
by: TH | last post by:
I am (still :) working on a recipe database. Now I am trying to figure out how to set it up for an ingredient search. What I want it to be able to do is three things: 1. Search based on just...
2
by: TH | last post by:
I am (still :) working on a recipe database. Now I am trying to figure out how to set it up for an ingredient search. What I want it to be able to do is to search by one ingredient, sometimes by...
5
by: Mark | last post by:
Hi Guru's, I have a login form which when an incorrect username or password is entered more then 3 times, a mail is sent containing the xp username, the username they have tried to open the...
9
by: skinnybloke | last post by:
Hi - I have 3 access queries which I run via 1 macro. Each of the queries now requires 2 parameters when they the run. The parameters are start and end dates. I have built the parameters...
3
by: Woodies_46 | last post by:
Hello all, I've just hit a brick wall. What I have is a form with a heap of tick boxs and text box on it and down the bottom a subform with shows the results. i also have a search button down...
2
by: Nightcrawler | last post by:
I need some input as to how the cleanest way to code the following. I have a aspx search page with a datalist displaying the results. Above the datalist are 2 textboxes and 2 dropdownlists. The...
25
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.