mysql学习(十一)嵌套查询 排序 分组

  1. select * from products where id in(select id from cats where name like '%java%');//查找类型中名字中包含java的的商品信息
  2. order by 字段名字 desc /asc
  3. select * from products order by price desc;//按照降序排列
  4. limit 
  5. select * from products order by price limit 1;//取出价格便宜的商品
  6. select * from products where id < 14 limit 0, 1 //id为14的上一条
  7. mysql> select * from products where id > 3 order by price desc limit 0, 1;
    +----+-----+------+-------+----------------+-----+
    | id | cid | name | price | desn | num |
    +----+-----+------+-------+----------------+-----+
    | 5 | 5 | java | 8.18 | this is a java | 3 |
    +----+-----+------+-------+----------------+-----+

  8. count()
  9. max()
  10. avg()
  11. min()
  12. sum()
  13. group by
  14. having
原文地址:https://www.cnblogs.com/zhoulikai/p/3361735.html