MYSQL字段截取

需求

  • 查询数据库中字段(xxx-xxx)格式数据,查出-后xxx数据最大的数据

处理

  • 查询字段结构
    这里写图片描述

  • -

        SELECT
            number ,
            substring_index(number , '-' , 1) AS source ,
            substring_index(number , '-' , - 1) AS target
        FROM
            table
        ORDER BY
            source DESC
        LIMIT 0 ,1
  • 查询出的数据
    这里写图片描述

语法:Mysql字符串截取总结:left()、right()、substring()、substring_index()

猜你喜欢

转载自blog.csdn.net/qq_28325291/article/details/82352734