zoukankan      html  css  js  c++  java
  • Mysql内置函数

    字符串函数

    select concat('hello','word','my') myname; // concat()  链接字符函数  输出 hellowordmy  myname是别名
    select lcase('MYSQL');                    //lcase()   转化成小写     输出 mysql 
    select length('string')                    //length()  输出字符串的长度
    select ltrim('  strimg');                //ltrim()  去除左边空格
    select rtrim('string  ');                //rtrim()  去除右边空格
    select repeat('php,',3);                    //repeat() 重复次数  输出  php,php,php,
    select replace('linux is very good','linux','php') ;  //replace()替换   输出 php is very good
    select substr('linux is very good',1,5);    //substr(),mysql 的起始位置是1,输出linux
    select space(10);                           //space();  生成10个空格

    数学函数

    select bin(192);                  //bin();  十进制转二进制  ,输出 11000000
    select celing(10.1);             //celing();  向上取整   输出 11
    select floor(10.1);              //floor();  向下取整  输出 10
    select max(col);               // max()  取最大值  聚合使用
    select min(col)                 //min()  取最小值  聚合使用
    select sqrt(4);                //sqrt()   开平方,输出2
    select rand();                // rand() 随机  select * from tablename order by rand()

    日期函数

    select curdate();                    //curdate();  当前日期  年月日
    select curtime();                    //curtime();  当前时间  时分秒
    select now();                         //now();     现在的日期和时间  年月日时分秒
    select unix_timestamp();                    //unix_timestamp();    返回当前unix时间戳
    select week('2015-10-10');             //week();       返回当年的第几周
    select year('2016-06-26');             //year();     输出 2016 ,返回当前的年份
    select datediff('2016-10-10','2016-10-20');       // 输出-10,返回两个日期相差几天
    select from_unixtime(1234567884); //返回时间戳对应的时间字符串
  • 相关阅读:
    (转载)C++ string中find() ,rfind() 等函数 用法总结及示例
    UVA 230 Borrowers (STL 行读入的处理 重载小于号)
    UVA 12100 打印队列(STL deque)
    uva 12096 The SetStack Computer(STL set的各种库函数 交集 并集 插入迭代器)
    uva 1592 Database (STL)
    HDU 1087 Super Jumping! Jumping! Jumping!
    hdu 1176 免费馅饼
    HDU 1003 Max Sum
    转战HDU
    hust 1227 Join Together
  • 原文地址:https://www.cnblogs.com/wt645631686/p/6868065.html
Copyright © 2011-2022 走看看