mysqlmysql-8.0compound-operator

How to use the compound operators of MySQL 8.0 in the simplest syntax?


enter image description here

https://www.w3schools.com/mysql/mysql_operators.asp

Came across this. I am studying MySQL as a beginner and I can't seem to find anything on the internet that works.

I can't even find them in https://dev.mysql.com/doc/refman/8.0/en/comparison-operators.html.

Could I have the simplest working syntax of how these compound operators work?

Thank you very much.


These are my attempts:

UPDATE tableName
SET intColumn += 5
WHERE id = 5;

UPDATE tableName
SET intColumn = ((intColumn) + 5)
WHERE id = 5;

UPDATE tableName
SET intColumn = ((SELECT intColumn FROM tableName WHERE id = 5) + 5)
WHERE id = 5;

-- works --
UPDATE tableName
SET intColumn = tableName.intColumn + 5
WHERE id = 5;
SELECT * FROM tableName;

@variables

SET @intVar = 0;
SELECT @intVar;
SET @intVar += 10;

-- works but += doesn't?
SET @intVar = @intVar + 50;
SELECT @intVar;

Solution

  • Mysql does not have compound operators. For the complete list of operators in mysql see mysql manual