With the help of the following MySQL statement, we can use SELECT to evaluate the expression -
SELECT expression;
The above statement does not refer to any table. Here are some examples -
mysql> Select 10 DIV 5; +----------+ | 10 DIV 5 | +----------+ | 2 | +----------+ 1 row in set (0.06 sec) mysql> Select 10*5; +------+ | 10*5 | +------+ | 50 | +------+ 1 row in set (0.00 sec) mysql> Set @var1 = 100, @var2 = 200; Query OK, 0 rows affected (0.00 sec) mysql> Select @Var1+@Var2; +-------------+ | @Var1+@Var2 | +-------------+ | 300 | +-------------+ 1 row in set (0.00 sec)
The above is the detailed content of How to use SELECT to evaluate an expression in MySQL without referencing any table?. For more information, please follow other related articles on the PHP Chinese website!