MySQL的单表查询

单表查询

1.查询所有字段
select      *     from       表名
2.查询指定字段
select   字段1,字段2    from    表名   
3.as
查询的结果中列名显示其他名字:
select   字段1  as   别名,字段2  as   别名     from    表名
4.条件查询
1)select  *  from   表名 where   age >/<  10;
2)去点重复的字段
select  distinct   sex   from 表名
3)in
select   from 表名  where  id (not)in (1,2,3)
4)between      and
select *   from 表名  where id  between2   and 4
5)like 模糊查询
select *   from 表名  where   name   like ‘%y’
%不限字数      _只能是一个字
6)and 满足所有条件     or满足任意条件
select *   from 表名  where   name=’’   and   sex=’’
4.排序 asc(默认的   升序)     desc(降序)
select   *   from 表名   order   by   age   desc/asc
5.限量 limit
select   *   from 表名   limit(1,3)
6.聚合函数
max()     min()     avg()    sum()    count()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值