Connecting Tech Pros Worldwide Forums | Help | Site Map

Build a search query based on multiple userinput from textboxes

thetaamommy@gmail.com
Guest
 
Posts: n/a
#1: Oct 30 '08
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.

Hugo Kornelis
Guest
 
Posts: n/a
#2: Oct 30 '08

re: Build a search query based on multiple userinput from textboxes


On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), thetaamommy@gmail.com wrote:
Quote:
>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
Hugo Kornelis
Guest
 
Posts: n/a
#3: Oct 30 '08

re: Build a search query based on multiple userinput from textboxes


On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), thetaamommy@gmail.com wrote:
Quote:
>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
Hugo Kornelis
Guest
 
Posts: n/a
#4: Oct 30 '08

re: Build a search query based on multiple userinput from textboxes


On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), thetaamommy@gmail.com wrote:
Quote:
>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
Hugo Kornelis
Guest
 
Posts: n/a
#5: Oct 30 '08

re: Build a search query based on multiple userinput from textboxes


On Thu, 30 Oct 2008 21:08:13 +0100, Hugo Kornelis wrote:
Quote:
>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
Dom
Guest
 
Posts: n/a
#6: Oct 31 '08

re: Build a search query based on multiple userinput from textboxes


On Oct 30, 4:06*pm, Hugo Kornelis
<h...@perFact.REMOVETHIS.info.INVALIDwrote:
Quote:
On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), thetaamo...@gmail.com wrote:
Quote:
Hi All
>
Quote:
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.
>
Quote:
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
thetaamommy@gmail.com
Guest
 
Posts: n/a
#7: Nov 3 '08

re: Build a search query based on multiple userinput from textboxes


Erland's article is what i needed, exactly

Thank you guys, for pointing me in the right direction !!
- TAAM


Closed Thread


Similar Microsoft SQL Server bytes