Syntax error How can SELECT, without reference to any table, be used to calculate expression in MySQL?

How can SELECT, without reference to any table, be used to calculate expression in MySQL?



With the help of following MySQL statement, we can use SELECT to calculate the expression −

SELECT expression;

The above statement is having no reference to any table. Followings 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)
Updated on: 2020-06-22T11:49:51+05:30

133 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements