1

How to pass multiple values in comma separated in single parameter - store processor MYSQL

I want to pass values like

$value = "('1','12','33'),('4','15','26'),('7','38','39'),('31','42','13')";

$sql = mysql_query("CALL addNetwork('$value')");
Developer
  • 11
  • 4
  • What is the error – iamsankalp89 Sep 27 '17 at 06:16
  • 1
    You cannot pass an array as a variable directly to a procedure. The usual workaround is to add them to a temporary table and then use that temporary table inside your procedure. Other, usually more complicated, methods would e.g. be to pass the values as one single string and then evaluate that string inside your procedure, e.g. split it or use it in dynamic sql. See [Pass array to MySQL stored routine](https://stackoverflow.com/q/8149545/6248528). – Solarflare Sep 27 '17 at 06:16
  • I think you can pass your multiple values as a single parameter, just like you did it, and put it in your insert statement – Tigran Babajanyan Sep 27 '17 at 06:17
  • How to pass multiple values as a single parameter, please help me. THis is my SP INSERT INTO tbl_survey_report(userId,categoryId,questionId) VALUES ; – Developer Sep 27 '17 at 06:20
  • Possible duplicate of [Pass array to MySQL stored routine](https://stackoverflow.com/questions/8149545/pass-array-to-mysql-stored-routine) – Solarflare Sep 27 '17 at 06:20
  • Did you at least read the linked question? Your stored procedure would be the *exact* use case of the first, marked answer. Just replace `SELECT * FROM Fruits WHERE Name IN ` with your code. If you need help with this: add the code you tried (=copy and pasted and replaced with your query) and the error you get to your question. – Solarflare Sep 27 '17 at 06:28

0 Answers0