- 使用比较运算符的子查询
符号:=,>,<,<=,<=,<>,!=,<=>
例子:SELECT goods_id,goods_name,goods_price FROM tdb_goods
WHERE goods_price > (SELECT AVG(goods_price) AS avg_price FROM tdb_goods)
ORDER BY goods_price DESC;
内查询:查找出商品的平均价格
外查询:输出大于平均价格的商品
若查询出来的数据多余一行,则可以使用any,some,all
例子:SELECT goods_id,goods_name,goods_price FROM tdb_goods
WHERE goods_price > ANY (SELECT * FROM tdb_goods WHERE goods_price >= '5000');