Usage of MySQL user Variables

Source: Internet
Author: User

MySQL database variables include MySQL System variables and MySQL user variables. The following describes the application of MySQL user variables for your reference and learning.

MySQL user variables:

Based on session variables, you can save values and pass them to the variables used by the next SQL statement in the same connection.
When the client connection exits, the variable is released.

Application scenarios of MySQL user variables:
If the same connection is not closed, some computation results will be saved for you.
For example
Select @ admin_id: = max (id) from user_info;
Select * from user_info where id = @ admin_id
The preceding two SQL statements are completed in the same connection.
In addition, note that there is only one @ before the user variable and two @ is used to access the system variable.

Too many business-related variables are defined, so the global variables of the system cannot be distinguished?
This type of problem can be solved through the structured system variables provided by mysql.

They have a unique representation:
Instance_name.test_var

An instance_name is added to a common variable. In this way, you can easily classify them. For example, app. test_var can be different from the system var.
 

Use of MySQL System Variables

Difference between NULL and MySQL NULL strings

In-depth study of MySQL result strings

MySQL string truncation Function Method

Number sorting in MySQL strings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.