Search Stored Procedure
-
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.
-
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.
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. -
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.
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
-
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.