If you want to share a variable across multiple sessions, you can use a global variable. It is visible to the session which had declared it. The values stored in a user-defined variable can be used in another SQL statement.įollowing are the characteristics of the User-defined variables. The User-defined variables are used to store the values generated from one SQL statement. Let us understand their usage with examples. MySQL database servers support the following types of variables. You can also store the single value output generated by a SQL query. The variables are used to store the static or dynamic values. Like all relational database management systems, MySQL also supports the concept of variables.
This article explains the variables in the MySQL database.