2017-05-26

--SUBSTR(addtime, 1, 10)
--substr(string string,num start,num length);
--string为字符串
--start为起始位置
--length为长度 SELECT d.uid,
SUBSTR(u.addtime, 1, 10) as 注册时间,
d.cid as cid
FROM user_extra_device d,
user u
where d.uid= u.id
and u.addtime>= "2017-01-09 00:00:00"
order by SUBSTR(u.addtime, 1, 10) --从左边开始截取3个字符
select left('example.com', 3)
--结果exa --从右边开始截取3个字符
select right('example.com', 3) --从字符串的第 4 个字符位置开始取,直到结束
select substring('example.com', 4)
--mple.com --从字符串的第 4 个字符位置开始取,只取 2 个字符
select substring('example.com', 4, 2) --从字符串的第 4 个字符位置(倒数)开始取,直到结束
select substring('example.com', -4)
--.com --从字符串的第 4 个字符位置(倒数)开始取,只取 2 个字符
select substring('example.com', -4, 2)

字符串截取mysql的更多相关文章

  1. MySQL字符串函数substring:字符串截取

    MySQL 字符串截取函数:left(), right(), substring(), substring_index().还有 mid(), substr().其中,mid(), substr() ...

  2. MySQL substring:字符串截取 (转载)

    MySQL 字符串截取函数:left(), right(), substring(), substring_index().还有 mid(), substr().其中,mid(), substr() ...

  3. mysql字符串截取

    mysql字符串截取 update zcat ) where lev1 is null; update zcat ) where lev2 is null; 函数: 1.从左开始截取字符串 left( ...

  4. MySQL 字符串截取相关函数

    MySQL 字符串截取相关函数 在工作中,可能需要将某些字段按某个分割符组成一个字符串作为字段值存取到数据库表中,比如某个任务对应三个结果,分别存储在不同的数据表中,这时可以将这三个不同表的主键按照约 ...

  5. Mysql字符串截取函数SUBSTRING的用法说明

    感觉上MySQL的字符串函数截取字符,比用程序截取(如PHP或JAVA)来得强大,所以在这里做一个记录,希望对大家有用. 函数: 1.从左开始截取字符串 left(str, length) 说明:le ...

  6. Mysql字符串截取总结:left()、right()、substring()、substring_index()

    同步首发:http://www.yuanrengu.com/index.php/20171226.html 在实际的项目开发中有时会有对数据库某字段截取部分的需求,这种场景有时直接通过数据库操作来实现 ...

  7. MySQL 字符串截取SUBSTRING()函数

    MySQL 字符串截取相关函数: 1.从左开始截取字符串 left(str, length) 说明:left(被截取字段,截取长度) 例: select left(content,200) as ab ...

  8. MySQL 字符串截取函数

    MySQL 字符串截取函数:left(), right(), substring(), substring_index().还有 mid(), substr().其中,mid(), substr() ...

  9. MySQL字符串函数:字符串截取

    MySQL 字符串截取函数:left(), right(), substring(), substring_index().还有 mid(), substr().其中,mid(), substr() ...

随机推荐

  1. mybatis提示Invalid bound statement (not found)错误的可能原因

    https://www.cnblogs.com/liaojie970/p/8034525.html

  2. CentOS 7 休眠系统

    CentOS 7的电源按钮只有关机和重启两项,但是可以用命令来休眠系统: 重启: $ systemctl reboot 退出系统并停止电源: $ systemctl poweroff 待机: $ sy ...

  3. hive有关函数

    1.窗口函数2015年4月份购买过的顾客及总人数 select distinct name,count(1) over() as cnt from test_window_yfwhere substr ...

  4. POJ 2299 Ultra-QuickSort (离散化)+【树状数组】

    <题目链接> 题目大意: 给你一段序列,问你如果每次只交换该序列相邻的两个元素,最少需要交换多少步才能够使该序列变为升序排列. 解题分析: 不难发现,其实本题就是让我们求原始序列的逆序对, ...

  5. 正确实现用spring扫描自定义的annotation

    背景在使用spring时,有时候有会有一些自定义annotation的需求,比如一些Listener的回调函数. 比如: @Service public class MyService { @MyLi ...

  6. React + antd 组件离开页面以后出现Can only update a mounted or mounting component 的解决办法

    做项目的过程中,来回切换页面时,一直遇到Can only update a mounted or mounting component 这个问题,原因是当离开页面以后,组件已经被卸载,执行setSta ...

  7. C#导出Excel时间格式问题

    Range range = worksheet.get_Range(worksheet.Cells[2, 1], worksheet.Cells[RowCount + 1, ColCount]);ra ...

  8. Element UI 树形表格,TreeGrid或TreeTable实现

    安装less npm install less --save-devnpm install less-loader --save-dev 模板代码 <template> <div c ...

  9. Self-introduction 自我介绍

    Hello everybody,我是一名计算机科学与技术大二的新生,来自小平爷爷的故乡——广安.我之所以说自己是新生,一方面因为我大一下学期才从广播电视学转到计科,另一方面是因为我又进入了新一学年的学 ...

  10. .ftl文件介绍

    freemarker的文件一般以后缀ftl,ftl文件的头上要写<#assign ww=JspTaglibs["/WEB-INF/webwork.tld"] /这样才能在ft ...