By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,574 Members | 1,968 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,574 IT Pros & Developers. It's quick & easy.

Build a search query based on multiple userinput from textboxes

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
Erland's article is what i needed, exactly

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

This discussion thread is closed

Replies have been disabled for this discussion.