zoukankan      html  css  js  c++  java
  • mysql substring()函数,字符串分割

    mysql> select * from test;
    +----+------------+-------+-----------+
    | id | name       | score | subject   |
    +----+------------+-------+-----------+
    |  1 | xiaoming   |    89 | shuxue    |
    |  2 | xiaohong   |    89 | shuxue    |
    |  3 | xiaohong   |    80 | english   |
    |  4 | xiaohong   |    80 | physics   |
    |  5 | xiaohong   |    80 | astronaut |
    |  6 | xiaoming   |    80 | physics   |
    |  7 | xiaoming   |    80 | astronaut |
    |  8 | xiaoming   |    80 | english   |
    |  9 | xiaobai    |    80 | astronaut |
    | 10 | 1.2xiaobai |    80 | english   |
    | 11 | 2.2xiaobai |    80 | physics   |
    | 12 | 3xiaobai   |    80 | shuxue    |
    | 13 | 123xiaohei |    80 | astronaut |
    | 14 | xiaohei    |    80 | shuxue    |
    | 15 | xiaohei    |    80 | physics   |
    | 16 | .12xiaohei |    80 | english   |
    +----+------------+-------+-----------+
    16 rows in set (0.00 sec)
    
    
    mysql> select substring(name,4,7) from test where id=3;
    +---------------------+
    | substring(name,4,7) |
    +---------------------+
    | ohong               |
    +---------------------+
    1 row in set (0.00 sec)
    
    
    mysql> select substring(name,4,1) from test where id=3;
    +---------------------+
    | substring(name,4,1) |
    +---------------------+
    | o                   |
    +---------------------+
    1 row in set (0.00 sec)
    
    
    mysql> select substring(name,4,2) from test where id=3;
    +---------------------+
    | substring(name,4,2) |
    +---------------------+
    | oh                  |
    +---------------------+
    1 row in set (0.00 sec)
    
    
    
    mysql> select substring(name,1,2) from test where id=3;
    +---------------------+
    | substring(name,1,2) |
    +---------------------+
    | xi                  |
    +---------------------+
    1 row in set (0.00 sec)
    
    
    
    mysql> select substring(name,0,5) from test where id=3;
    +---------------------+
    | substring(name,0,5) |
    +---------------------+
    |                     |
    +---------------------+
    1 row in set (0.00 sec)

  • 相关阅读:
    Remote Procedure Call (RPC) Locator与X3
    Delphi的悬浮窗口
    改变CSS样式
    JavaScript 打印Web页面指定区域的信息
    判断页面元素存在与否
    如何处理HTML标签属性
    jQuery 获取和设置表单元素
    如何添加/移除CSS类
    处理网页内容
    正则表达式 收集
  • 原文地址:https://www.cnblogs.com/sea-stream/p/11307774.html
Copyright © 2011-2022 走看看