How to assign variables to mysql stored procedures
Editor to share with you how the mysql stored procedure variable assignment, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Methods: 1, the use of set statement variable assignment, syntax for "set variable name = value or assignment statement"; 2, the use of query statements and into keyword variable assignment, syntax for "SELECT C1, c2...INTO @ v1, @ v2...FROM table name WHERE condition".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How to assign variables to mysql stored procedures
The MySQL variable assignment is just a pit. There are two ways to fill this hole.
The first is well known: set variable name = value / assignment statement
The second is: select … Into variable name... ; or select... Into variable name
First, I read on the Internet that many people say that @ match should be added before the variable name, but in fact, it is not necessary. There are only some special cases that must be @ match. Most of the time, it does not add or affect the use of stored procedures.
For example:
Set gaming exchangeholders gamedb.tbbread exchangeholders exchangeholders gamedb.tbshares exchangeholders exchangeholders gamedb.tbbeans exchangeholders exchangeholders gamedb.tbflowers exchangeholders exchangeholders * this is actually the same effect.
Second, this is even more lame. I saw other people use it in the clouds. Then I tried it several times before I found out. It is quite useful ~ the examples are as follows
Such as:
1.select count (*) into g_err from information_schema.TABLES t where t.TABLEX SCHEMA games gamedb' and t.TABLE_NAME=concat ('tb_recharge_',g_year); 2.select count (*) from information_schema.TABLES t where t.TABLEX SCHEMAX games gamedb' and t.TABLE_NAME=concat (' tb_recharge_',g_year) into g_err / * the two effects are the same * / the above is all the content of the article "how to assign variables to mysql stored procedures". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!