zoukankan      html  css  js  c++  java
  • MySQL 常用函数列表

    一、数学函数

    select SQRT (2) --取平方根
    select ABS (-234) --取绝对值
    select FLOOR (COUNT (*)/5.0) from news --取小于这个小数的最大整数
    select CEILING (COUNT (*)/5.0) from news --取大于这个小数的最小整数
    select ROUND (4.523,1) --保留小数点后几位

    二、字符串函数

    select LOWER ()--大写字母转成小写字母
    select UPPER ()--小写字母转成大写字母
    select LTRIM ()--压缩左边的空格
    select RTRIM ()--压缩右边的空格
    select LEFT (Title ,5)--从左边截取几个字符
    select RIGHT (Title ,5)--从右边截取几个字符
    select REVERSE (Title ) from news --对字符串进行翻转
    select CHARINDEX ('中国',title ) from news --这个字符串在这个列的哪个位置出现

    三、替换字符串

    select REPLACE (Title ,'中国','美国')from news --把title表中的中国替换成美国
    select STUFF (Title ,3,4,'china') from news --替换的列名,从第几个位置开始,替换几个字符,以什么字符串来代替

    四、其他函数

    select RAND () --随机数生成函数 0-1之间
    select LEN ('china') --取字符串长度
    select GETDATE () --获取当前时间
    select YEAR (sbrithday ) from student --取日期时间的年份
    select MONTH () -- 取日期时间的月份
    select DAY () --取日期时间的天数
    select DATEPART (DD/MM/YY/HH/MI/SS,sbrithday) from student -- 取日期时间的部分(日/月/年/小时/分钟/秒)
    select CAST (123 as varchar(20)) --转换数据类型

    2016.6.7    孤独夜莺

  • 相关阅读:
    iOS 页面之间的转场动画控制器间的转换
    C C语言中关键词,以及知识点复习
    iOS Swift基础知识代码
    LeetCode-Kth Smallest Element in a Sorted Matrix
    LeetCode-Design Phone Directory
    LeetCode-Longest Increasing Path in a Matrix
    LeetCode-Pathcing Array
    LeetCode-Wiggle Sort
    LeetCode-Odd Even Linked List
    LeetCode-Verify Preorder Serialization of a Binary Tree
  • 原文地址:https://www.cnblogs.com/hanqishihu/p/5565961.html
Copyright © 2011-2022 走看看