Why doesn't the stored procedure call return anything?

I made a stored procedure with a parameter. When I call this procedure without error, I am not shown any results. What's wrong with this code?

 drop PROCEDURE if exists `getUsersByContact`;

 delimiter $$
 Create PROCEDURE `getUsersByContact`(
   IN contact1 VARCHAR(10)
 )
 BEGIN
     SELECT id,name FROM tbl_user WHERE contact = contact1;
END $$
delimiter ;

      

When I call it

 call getUsersByContact('9999999999');

      

It doesn't return any rows and there is no error in phpmyadmin. However, when I use the out parameter and call the stored procedure and select that variable, it works fine. I have also tried this link and this link .

+3


source to share


2 answers


I am adding my answer in the belief that it might be helpful to others.



I was struggling with the same problem, but when I called this procedure in mysqlworkbench it worked like a charm. So maybe this is a phpmyadmin issue as @a_horse_with_no_name suggests.

0


source


When running a request inside SP, It will work!

 SELECT id,name
  FROM tbl_user 
  WHERE contact = `contactname`;

      

But this one won't work.



SELECT id,name
 FROM tbl_user
 WHERE contact = contact1;

      

You can find the reason here: http://mysqldb.bigresource.com/SELECT-INTO-returns-null-in-Stored-Procedure-Jx95y6IPJ.html

0


source







All Articles