zoukankan      html  css  js  c++  java
  • mysql字符串用法

    replace(str,from_str,to_str)
    --用字符串to_str替换字符串str中的子串from_str并返回
    
    --mysql> select replace('www.mysql.com', 'w', 'ww');
    --  -> 'wwwwww.mysql.com'
    
    
    --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)
    
    
    concat(left(reg2 / install *100, 5), '%') as 注册率
    
    $sql="select concat(id,"-",con) as res from article where id=1"
    
    
    --#身份证件号码前"'",避免输出后显示为科学计算法
    select uid,CONCAT(" '",cardno) as "身份证件号码" from  user_authentic  where state =2
    

      

  • 相关阅读:
    设计模式之里氏替换原则
    设计模式之依赖倒转原则
    设计模式之接口分离原则
    spring 集成 kafka producer(KafkaTemplate)
    jmeter 分布式
    ant+Jenkins+jmeter
    pycharm+git+github项目上传
    Python_pip下载不下来源解决方案
    linux_python3环境搭建
    Jenkins+Git+Github+Python自动化化接口项目例子
  • 原文地址:https://www.cnblogs.com/dengyg200891/p/6907653.html
Copyright © 2011-2022 走看看