Build a search query based on multiple userinput from textboxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • thetaamommy@gmail.com

    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.
  • Hugo Kornelis

    #2
    Re: Build a search query based on multiple userinput from textboxes

    On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), thetaamommy@gma il.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:


    --
    Hugo Kornelis, SQL Server MVP
    My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

    Comment

    • Hugo Kornelis

      #3
      Re: Build a search query based on multiple userinput from textboxes

      On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), thetaamommy@gma il.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

      Comment

      • Hugo Kornelis

        #4
        Re: Build a search query based on multiple userinput from textboxes

        On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), thetaamommy@gma il.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

        Comment

        • Hugo Kornelis

          #5
          Re: Build a search query based on multiple userinput from textboxes

          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

          Comment

          • Dom

            #6
            Re: Build a search query based on multiple userinput from textboxes

            On Oct 30, 4:06 pm, Hugo Kornelis
            <h...@perFact.R EMOVETHIS.info. INVALIDwrote:
            On Thu, 30 Oct 2008 12:06:29 -0700 (PDT), thetaamo...@gma il.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

            Comment

            • thetaamommy@gmail.com

              #7
              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


              Comment

              Working...