在mysql中,这个标记的含义是什么?

时间:2022-06-29 21:19:30

I don't know What's the meaning of this mark? := in MySQL Um... for example in Code.

我不知道这个标记是什么意思?:在MySQL =嗯…例如在代码。

  select @RN:=@RN+1 as no, ...
  from Employee
  where EmployeeNumber='*'

thank you.

谢谢你!

4 个解决方案

#1


1  

That's referencing a bind variable. For example say it's PHP, that will replace that reference with a variable.

它引用了一个绑定变量。例如,它是PHP,它将用一个变量替换那个引用。

#2


1  

It is binded variable. It will referenced later on while executing the query.

它是绑定变量。稍后在执行查询时将引用它。

#3


1  

For the query you've given, there is no effect in time you executed the query.

对于您所提供的查询,在执行查询时没有效果。

After the query executed, you can execute a query like this,

执行查询后,可以执行如下查询:

select @RN

This will give you the previous @RN value.

这将给出先前的@RN值。

The variable @RN is initially 0, and you add up +1 every query.

变量@RN最初是0,每一个查询加1。

That is, you will have executed query count in @RN variable anytime you want.

也就是说,您可以随时在@RN变量中执行查询计数。

#4


0  

It assigns a value to a variable. Same as the = operator in C style languages.

它为变量赋值。与C语言中的=运算符相同。

In this case you will get NULL's for that column unless you initialize @RN before you run the query (because NULL+1 returns NULL).

在这种情况下,除非在运行查询之前初始化@RN(因为NULL+1返回NULL),否则该列将获得NULL。

If you initialize it you will get sequential integers in the result.

如果初始化它,结果将是连续整数。

#1


1  

That's referencing a bind variable. For example say it's PHP, that will replace that reference with a variable.

它引用了一个绑定变量。例如,它是PHP,它将用一个变量替换那个引用。

#2


1  

It is binded variable. It will referenced later on while executing the query.

它是绑定变量。稍后在执行查询时将引用它。

#3


1  

For the query you've given, there is no effect in time you executed the query.

对于您所提供的查询,在执行查询时没有效果。

After the query executed, you can execute a query like this,

执行查询后,可以执行如下查询:

select @RN

This will give you the previous @RN value.

这将给出先前的@RN值。

The variable @RN is initially 0, and you add up +1 every query.

变量@RN最初是0,每一个查询加1。

That is, you will have executed query count in @RN variable anytime you want.

也就是说,您可以随时在@RN变量中执行查询计数。

#4


0  

It assigns a value to a variable. Same as the = operator in C style languages.

它为变量赋值。与C语言中的=运算符相同。

In this case you will get NULL's for that column unless you initialize @RN before you run the query (because NULL+1 returns NULL).

在这种情况下,除非在运行查询之前初始化@RN(因为NULL+1返回NULL),否则该列将获得NULL。

If you initialize it you will get sequential integers in the result.

如果初始化它,结果将是连续整数。