How to remove part of string in mysql?

后端 未结 5 1782
既然无缘
既然无缘 2020-12-15 20:27

In one table of my database I have strings which looks like this one:

sometext-othertext

How to remove the text including dash with SELECT

5条回答
  •  甜味超标
    2020-12-15 21:33

    just use :

    SELECT SUBSTRING_INDEX('sometext-othertext', '-', 1);
    

    Function have 3 prameters, first that is a text, second is object for spliting, and number (1) for getting you want (the controller)

提交回复
热议问题