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

    字符串函数:

    concat ('xiao','qun');
    =====>xiaoqun

    insert('woshixiaozou',10,3,'qun');
    =====> woshixiaoqun

    select lower('XIAOQUN'),upper('xiaoqun');
    =====> xiaoqun XIAOQUN

    select left('xiaoqunwoshi',7),right('xiaoqunwoshi',5);
    =====>xiaoqun woshi

    select lpad('xiaoqun',15,'woshi');
    =====>woshiwosxiaoqun

    select rpad('xiaoqun',15,'woshi');
    =====>xiaoqunwoshiwos

    select ltrim(' |xiaoqun),rtrim('xiaoqun| ');
    =====>|xiaoqun xiaoqun|

    select repeat('xiao',5);
    =====>xiaoxiaoxiaoxiaoxiao

    select replace('xiaoqun0318','0318','1314');
    =====>xiaoqun1314
    数值函数:

    select abs(n); 返回n的绝对值
    select ceil(n); 返回大于n的最小整数
    select floor(n); 返回小于n的最大整数
    select mod(m,n); 返回m/n的模
    select rand( ); 随机返回一个0-1之间的数据
    select round(m,n); 返回m的四舍五入的有n位的数值
    select truncate(m,n);返回m截断为n位的值


    时间和日期函数:

    select curdate(); 返回当前日期0000-00-00
    select curtime(); 返回当前时间00:00:00
    select now(); 返回日期加时间
    select unix_timestamp(now()); 返回日期date的Unix的时间戳
    select from_unixtime(); 返回Unix的日期 与上面的互为逆运算
    select hour(curtime()),minute(curtime()); 返回所给时间的时间 与 分钟
    select week(now()),year(now());前面返回现在是今年的第几周,后面返回时哪一年;
    select monthname(now()); 返回现在月份的英文月份函数;


    select if(value,t,f) from table_name; 如果value为真 则 返回t
    select ifnull(value1,value2) from table_name; 如果value值不为空返回value1,如果是则返回value2 一般用于替换null
    select case when value1 then result.....else default end from table_name;


    其他常用函数:

    select database(); 返回当前数据库的名
    select version(); 返回当前数据库的版本
    select user(); 返回当前登录用户名
    select inet_aton(ip);返回当前IP的数字表示
    select inet_ntoa(num);返回数字代表的IP地址
    select password(str); 返回字符串str的加密版本
    select md5(); 返回字符串str的md5值

    如有错误,望费心指出。 感激涕零。
  • 相关阅读:
    Registering a Visual Studio .Net AddIn without an Installer
    广州的.Net Fans俱乐部的T恤和Logo的设计
    模板控件概念(转)
    随笔-在广州.Net俱乐部的一个下午
    快速备份Outlook中的资料
    web.config文件详解
    使用RAPI库操作移动设备——C#语言描述 (转贴)
    Ready to Rock 撼动未来:SQL Server 2005 ,Visual Studio 2005, BizTalk Server 2006 新品发布会 报名
    IBM Rational Solutions V2003
    VS.Net 2003 IDE 插件开发指南
  • 原文地址:https://www.cnblogs.com/zouxiaopq/p/6165824.html
Copyright © 2011-2022 走看看