Home >Database >Mysql Tutorial >mysql subquery example analysis
Subquery can be understood as a query nested in other statements, so we have different usage methods for different query results.
1. The subquery is a single-value result, so you can use comparison operators such as = and > on it.
# 查询价格最高的商品信息 select * from t_product where price = (select max(price) from t_product)
2. The subquery is a multi-valued result, so you can use [not]in (subquery result) or >all (subquery result) for it.
# 查询价格最高的商品信息 SELECT * FROM t_product WHERE price >=ALL(SELECT price FROM t_product)
The above is the detailed content of mysql subquery example analysis. For more information, please follow other related articles on the PHP Chinese website!