• 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)

  • 相关阅读:
    洛谷P3384 【模板】树链剖分
    hdu3518 Boring counting(后缀数组)
    CSL 的密码(后缀数组)
    洛谷P3809 【模板】后缀排序
    洛谷P2387 [NOI2014]魔法森林(LCT)
    洛谷P3366 【模板】最小生成树(LCT)
    Stanford机器学习课程(Andrew Ng)
    操作系统存储器管理选择题精练
    实验12:Problem I: 成绩排序
    实验12:Problem H: 整型数组运算符重载
  • 原文地址:https://www.cnblogs.com/sea-stream/p/11307774.html
Copyright © 2020-2023  润新知