select基本操作(基础篇)

目录

一、去重查询

二、使用LIMIT限制结果集

三、修改菜单名

四、范围

五、子查询

六、字符匹配

七、使用聚合函数汇总数据

八、UNION(并)

九、case函数

十、匹配年月日

十一、字符串截取之substring_index

十一、字符串截取之substring

十二、排序

十三、连接查询


一、去重查询

distinct 是去重查询关键字

实例:selcte distint unversity from user

二、使用LIMIT限制结果集

LIMIT 子句可以被用于强制 SELECT 语句返回指定的记录数。

LIMIT 接受一个或两个数字参数。参数必须是一个整数常量。

如果只给定一个参数,它表示返回最大的记录行数目。

如果给定两个参数,第一个参数指定第一个返回记录行的偏移量,第二个参数指定返回记录行的最大数目。

为了检索从某一个偏移量到记录集的结束所有的记录行,可以指定第二个参数为 -1。

初始记录行的偏移量是 0(而不是 1)。

实例:select device_id from user_profile limit 2

三、修改菜单名

实例:select device_id as user_infos_examplefrom user_profile limit 2

四、范围

between:双边范围都包含

实例:select device_id,gender,age from user_profile where age between 20 and 23

不包含:!=或者not in

实例:select device_id,gender,age,university from user_profile where university != '复旦大学'

不为空:!=''或者age is not null

select device_id,gender,age,university from user_profile where age != ''

五、子查询

实例:select device_id,gender,age,university,gpa from user_profile where device_id in (select device_id from user_profile where gpa > 3.5 and university = '山东大学')or device_id in (select device_id from user_p

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值