Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Search Stored Procedure

Search Stored Procedure

Scheduled Pinned Locked Moved Database
databasemysql
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul McGann
    wrote on last edited by
    #1

    I'm trying to create a search stored proc with mysql. the procedure uses roughly 7 parameters and depending upon the users choice of dropdownlists and datepickers i want to return the results. for instance: 2 dropdowns with ID so that user can select WHERE ID > Parameter_ID WHERE ID < Parameter_ID has anyone attempted something similiar and if so could they point me in a good directly for some resources.

    E M P 3 Replies Last reply
    0
    • P Paul McGann

      I'm trying to create a search stored proc with mysql. the procedure uses roughly 7 parameters and depending upon the users choice of dropdownlists and datepickers i want to return the results. for instance: 2 dropdowns with ID so that user can select WHERE ID > Parameter_ID WHERE ID < Parameter_ID has anyone attempted something similiar and if so could they point me in a good directly for some resources.

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      where (param1 is null OR param1 > someColumn) AND (param2 is null OR param2 = someColumn etc, its ugly but does work.

      Need custom software developed? I do C# development and consulting all over the United States.
      If you don't ask questions the answers won't stand in your way.
      Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.

      1 Reply Last reply
      0
      • P Paul McGann

        I'm trying to create a search stored proc with mysql. the procedure uses roughly 7 parameters and depending upon the users choice of dropdownlists and datepickers i want to return the results. for instance: 2 dropdowns with ID so that user can select WHERE ID > Parameter_ID WHERE ID < Parameter_ID has anyone attempted something similiar and if so could they point me in a good directly for some resources.

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Ennis reply is the correct method, however be careful with this one, string too may together, and 7 is too many, and it can grind your query to a halt. Best bet is to try and force some required filters and apply them first depending on your data size. I have even gone down the path of using a case statement to get the first valid filter, drop the results into a temp table and apply a secondary set of filters to the temp table to improve performance.

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        • P Paul McGann

          I'm trying to create a search stored proc with mysql. the procedure uses roughly 7 parameters and depending upon the users choice of dropdownlists and datepickers i want to return the results. for instance: 2 dropdowns with ID so that user can select WHERE ID > Parameter_ID WHERE ID < Parameter_ID has anyone attempted something similiar and if so could they point me in a good directly for some resources.

          P Offline
          P Offline
          pmpdesign
          wrote on last edited by
          #4

          Try http://www.codeproject.com/KB/database/AdvancedSearchSP.aspx[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups