In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.