• mysql 函数大全


     

     CANCAT函数需要注意,任何字符串和NULL 连接 结果都为NULL;

    如果想产生0-100的随机数 可以使用 ceil(100*rand()) 2个函数的组合形式来实现。

     

    DATE_ADD(date,INTERVAL expr type)函数:返回与所给日期date 相差INTERVAL 时间段的日期

    expr 是一个表达式,即相差的时间值,type为表达式的类型,即下表的表达式类型

     

    if(表达式,A,B);

    当if函数中的表达式为ture的时候则输出值A 否则输出值B。

    例:update salary set sex = if(sex='m','f','m');

    case 字段 when 表达式A then A

           when 表达式B then B

           else C end;

    当字段 满足表达式A 则值为A  满足表达式B 则值为B 否则为C,else也可不写。

    例:update salary set sex = case sex when "m" then "f" when "f" then "m" end; 

    mod(num1, num2) ;

    mod函数表示去num1除与num2之后的余数。

    例:select * from cinema where mod(id, 2)=1 and description <> 'boring' order by rating desc

     

    exists(boolean)

    exists函数在查询时 判断括号内的表达式是否为True,如果为true则返回一条数据,反之则不返回数据。

    例:select name from Customers c where not exists (select 1 from Orders o where c.Id = o.CustomerId)

    当 Customers表中的id 与Orders表中的CustomerId比较时 如果相等,则说明存在 则customers 返回对应ID的数据。

  • 相关阅读:
    lua学习之循环求一个数的阶乘
    lua元表学习
    ArrayList与List性能测试
    安卓开发线程
    安卓开发
    全局设置导航栏
    LinearLayout
    安卓布局ConstraintLayout
    安卓网络请求和图片加载
    安卓启动页面
  • 原文地址:https://www.cnblogs.com/culushitai/p/10312759.html
Copyright © 2020-2023  润新知