Reputation: 1792
Is there a difference between @var := 0; and @var = 0; ?
With and without the colon? What does that do?
Upvotes: 1
Views: 86
Reputation: 55213
In the case of SET, they are synonymous:
SET @var := 1234;
SET @var = 1234;
But =
acts as a conditional operator when used in a SELECT
:
SELECT @var := 1234; -- 1234
SELECT @var = 1234; -- 1
So it's generally best to stick to :=
for assignment to avoid confusion.
Upvotes: 3