- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Using the entire expression in MySQL WHERE clause?
Let us see an example and create a −
mysql> create table DemoTable1406 -> ( -> Value int -> ); Query OK, 0 rows affected (0.47 sec)
Insert some records in the table using insert −
mysql> insert into DemoTable1406 values(10); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1406 values(50); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1406 values(40); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable1406 values(30); Query OK, 1 row affected (0.11 sec)
Display all records from the table using select −
mysql> select * from DemoTable1406;
This will produce the following output −
+-------+ | Value | +-------+ | 10 | | 50 | | 40 | | 30 | +-------+ 4 rows in set (0.00 sec)
Following is the query to use the entire expression −
mysql> select Value+10 as ExpectedValue -> from DemoTable1406 -> where Value+10=40;
This will produce the following output −
+---------------+ | ExpectedValue | +---------------+ | 40 | +---------------+ 1 row in set (0.00 sec)
Advertisements