mysql基础⑤

一,order by 与limit查询

 1.价格由高到低排序,降序

select goods_id,goods_name,cat_id,shop_price from goods order by shop_price desc;

2.价格由低到高排序,升序

select goods_id,goods_name,cat_id,shop_price from goods order by shop_price asc;

3.按发布时间由早到晚排序

select goods_id,goods_name,cat_id,shop_price from goods order by goods_id asc;

4.按栏目由低到高排序,栏目内部按价格由高到低排序

select goods_id,goods_name,cat_id,shop_price from goods order by cat_id asc,shop_price desc;

 二where子查询

查询最新的商品,以goods_id为最新

原文地址:https://www.cnblogs.com/ctx1989/p/5910862.html