- 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
What is the use of comparison operators with MySQL subquery?
The subquery can return at most one value. The value can be the result of an arithmetic expression or a column function. MySQL then compares the value that results from the subquery with the value on the other side of the comparison operator. MySQL subquery can be used before or after any of the comparison operators like =, >, >=, <, <=, !=, <>, <=>. Following is the example in which we are using a subquery with a < comparison operator.
Example
mysql> SELECT * from Cars WHERE Price < (SELECT AVG(Price) FROM Cars); +------+--------------+---------+ | ID | Name | Price | +------+--------------+---------+ | 1 | Nexa | 750000 | | 2 | Maruti Swift | 450000 | | 5 | Alto | 250000 | | 6 | Skoda | 1250000 | | 8 | Ford | 1100000 | +------+--------------+---------+ 5 rows in set (0.00 sec)
Similarly, the subquery can be used with other comparison operators too.
Advertisements