mysql -标量子查询-案例

时间:2020-07-01 12:14:56   收藏:0   阅读:78

技术图片

 

把价格最高的商品取出来???

select * from goods order by goods_price desc limit 1;

技术图片

 

 可是价格最高的可能有很多条数据呢?

所以,换一种方式

1,查出最高的价格

select max(goods_price) from goods;

2,根据最高价查询

select * from goods where goods_price = (select max(goods_price) from goods);

技术图片

 

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!