467,917 Members | 1,397 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,917 developers. It's quick & easy.

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
  • viewed: 4157
Share:
6 Replies
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by AaronV | last post: by
3 posts views Thread by RiceGuy | last post: by
1 post views Thread by TH | last post: by
2 posts views Thread by TH | last post: by
5 posts views Thread by Mark | last post: by
3 posts views Thread by Woodies_46 | last post: by
2 posts views Thread by Nightcrawler | last post: by
25 posts views Thread by pereges | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.