Home > Database > Mysql Tutorial > What does @ mean in mysql

What does @ mean in mysql

下次还敢
Release: 2024-04-26 05:48:12
Original
653 people have browsed it

The @ symbol in MySQL has two uses: specifying variables (@variable name) and connecting table or column names (@table name or @column name), indicating the alias of a temporary or derived table in the database.

What does @ mean in mysql

The meaning of @ symbol in MySQL

@ symbol has two main uses in MySQL:

1. Specify variables

@ symbol is used to specify variables, its syntax is:

<code>@变量名</code>
Copy after login

For example:

<code>SET @my_variable := 10;</code>
Copy after login

This will create a variable named @my_variable and set its value to 10.

2. Join table or column name

When the @ symbol is used with a table name or column name, it indicates that the object is a temporary or derived table in the database alias. This is typically used with temporary tables or stored procedures.

For example:

<code>SELECT * FROM table_name @alias;</code>
Copy after login

This will create an alias for the table_name table named @alias.

Note:

  • Variable names are case-sensitive, but aliases are not case-sensitive.
  • When specifying a variable, the @ symbol must follow the variable name without spaces.
  • When specifying an alias, the @ symbol must precede the table name or column name.

The above is the detailed content of What does @ mean in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template