Home > Database > Mysql Tutorial > MySQL的5种子句查询_MySQL

MySQL的5种子句查询_MySQL

WBOY
Release: 2016-06-01 13:10:37
Original
1027 people have browsed it

MySQL的5种子句查询

1.where

where shop_price>300 and shop_price<500where shop_price<300 or shop_price>500
Copy after login
  • between
where shop_price between 300 and 500
Copy after login
where shop_price >= 300 and shop_price <= 500
Copy after login
  • in
where cat_id in(4,5,6)cat_id=4 cat_id=5 cat_id=6
Copy after login

2.group by 分组查询

group by 需要配合一下5个聚合函数使用:

  • max
  • min
  • avg
  • sum
  • count
select cat_id.max(shop_price) from goods group by cat_id;
Copy after login

3.having

having必须作用于where之后

select cat_id,sum(shop_price*goods_number) as huokuan from goods group by cat_id having huokuan>20000;
Copy after login

4.order by

  • asc---顺序,默认值
  • desc---倒序

5.limit

limit[偏移量],条数
偏移量默认为0


source:php.cn
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