Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8535483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:26:31+00:00 2026-06-11T10:26:31+00:00

I want to create a MySQL stored procedure (SP) with input parameters. However, the

  • 0

I want to create a MySQL stored procedure (SP) with input parameters.

However, the number of parameters cannot be determined at the time of writing the SP.
(The scenario is that the users will have multiple options to choose. The options chosen will form the search criteria:

select ... 
where prod_category = option1 && option2 && option3 &&...

So, if someone chooses only option1 and option2, only 2 parameters will be sent. Sometimes it may be 50+ options are chosen and hence 50+ parameters will have to be sent.)

So, I have 3 questions:
1. Can I handle such a scenario using MySQL stored procedures (SP)?
2. Is the SP the professional way to handle such scenario?
3. If SP is not the professional way to handle these scenarios, is there anything else that will handle these searches efficiently? The search is the core functionality of my application.

Thanks in advance for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:26:32+00:00Added an answer on June 11, 2026 at 10:26 am

    MySQL stored procedures accept only a fixed number of arguments. You can build your list of parameters and values delimited on a single string parameter and then process them on your procedure, or use your application language to build the query instead.

    From http://forums.mysql.com/read.php?98,154749,155001#msg-155001

    No, MySQL sprocs accept only a fixed number of arguments. ISO SQL is
    somewhat optimised for correct RDBMS logic (unless you were to ask EF
    Codd, CJ Date or Fabian Pascal), but in many ways SQL is quite
    literal, so if SQL seems to make what you are trying to do very
    difficult, it could be that your design needs another look, in this
    case aspects of the design that require repeated multiple ad hoc
    deletions.

    If such deletions are unavoidable, here are three options. First, in
    an application language build the delete query to include
    comma-delimited string of IDs. Second, pass such a string to an sproc
    that PREPAREs the query using such a string. Third, populate a temp
    table with the target IDs and write a simple join query that deletes
    the joined IDs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a stored procedure in MySQL that took a list
I want to create a MYSQL Stored procedure when I insert data into the
I have stored procedure that I created in MySQL and want PHP to call
I want to create a new column in a MYSQL table that has Fn
I am trying to create stored procedure in mysql admin. I am hosting a
I want to be able to get some output from mysql stored procedure within
I am using mysql which i have a stored procedure which has an input
i want to execute a mysql stored procedure from mysql command prompt in phpmyadmin.stored
I have a MySQL stored procedure that uses a temporary table. Assume that my
I want to create a stored procedure with 4 insert and i have this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.