Passing Parameters to MySQL Stored Procedure

MySQL Stored Procedure parameter does not take @ sign. The variables are declared using identifier name (without the @sign). In some editors like PHPMYADMIn, you might declare a variable with @ sign and may not get any error but your code will not work correctly. To fix this issue, simply remove @sign.

This also leads to an interesting scenario. If your parameter name is same as one of your table field, you will have to use alias to different the two. For example

My variable name is ID, but that is also the field inside my student table. To fix the issue, use this syntax

select * from student S where S.ID = ID


Passing Parameters to SQL Stored Procedure


This entry was posted in MYSQL and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s