user2495385
user2495385

Reputation: 27

what's meaning of this mark ":=" in mysql?

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

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

thank you.

Upvotes: 3

Views: 285

Answers (4)

Vatev
Vatev

Reputation: 7590

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

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).

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

Upvotes: 0

totten
totten

Reputation: 2817

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.

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

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

Upvotes: 1

Starx
Starx

Reputation: 78971

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

Upvotes: 1

Mr. Alien
Mr. Alien

Reputation: 157314

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

Upvotes: 1

Related Questions