Home  >  Article  >  Database  >  What is the use of comparison operators in MySQL subqueries?

What is the use of comparison operators in MySQL subqueries?

WBOY
WBOYforward
2023-08-25 22:41:111298browse

MySQL 子查询中的比较运算符有什么用?

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 result of the subquery to the value on the other side of the comparison operator. MySQL subqueries can be used before or after any comparison operator, such as =, >, >=, , . Below is our example using subquery with

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, subqueries can also be used with other comparison operators.

The above is the detailed content of What is the use of comparison operators in MySQL subqueries?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete