Home > Database > Mysql Tutorial > body text

mysql subquery example analysis

PHPz
Release: 2023-05-28 10:07:05
forward
946 people have browsed it

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)
Copy after login

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)
Copy after login

The above is the detailed content of mysql subquery example analysis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!