Differences between the value assignment of SQL server and mysql Variables

Source: Internet
Author: User

Both SQL server and mysql are our frequently used database systems. Next we will introduce the differences between the values of SQL server and mysql variables, and hope to enlighten you.

Variables in SQL server must be affirmed first and then assigned values:

The local variables are identified with one @, and the global variables with two @ common global variables are generally defined );

Declare the local variable Syntax: declare @ variable name data type; for example, declare @ num int;

Value assignment: There are two methods: @ num is the variable name, and value is the value)

Set @ num = value; or select @ num = value;

If you want to obtain a field value in the query statement, you can use select to assign values to the variable, as shown below:

Select @ num = field name from table name where ......

You do not need to declare the value assignment of mysql variables beforehand. You can simply use "@ variable name" when using it.

First usage: set @ num = 1; or set @ num: = 1; // use the variable to save the data. Use the @ num variable directly.

Second usage: select @ num: = 1; or select @ num: = field name from table name where ......

Note that the above two values can be set with "=" or ": =", but ": =" must be used for select"
 

Take you to understand MySQL random string functions

In-depth study of MySQL result strings

MySQL string truncation Function Method

Differences between MySQL string column types

Usage of MySQL user Variables

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.