
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Use SELECT Without Table Reference 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)
Advertisements