Home > Database > Mysql Tutorial > How to use SELECT to evaluate an expression in MySQL without referencing any table?

How to use SELECT to evaluate an expression in MySQL without referencing any table?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-09-04 21:21:03
forward
930 people have browsed it

如何在不引用任何表的情况下使用 SELECT 来计算 MySQL 中的表达式?

With the help of the following MySQL statement, we can use SELECT to evaluate the expression -

SELECT expression;
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template