What is the difference between := and = operators in MySql?
And which place is it stable to use these two?
Is it the same or just an alternative?
What is the difference between := and = operators in MySql?
And which place is it stable to use these two?
Is it the same or just an alternative?
In a SET statement, both := and = are assignment operators.
In a SELECT statement, := is an assignment operator and = is an equality operator.
SET @a = 1, @b := 2;
SELECT @a, @b; -- 1, 2
SELECT @a = @b; -- 0 (false)
SELECT @a := @b; -- 2
SELECT @a, @b; -- 2, 2
SELECT @a = @b; -- 1 (true)