首页 > 编程知识 正文

mysql 删除部分数据,MySQL删除一个字段

时间:2023-05-04 07:20:08 阅读:179705 作者:450

inonetableofmydatabaseihavestringswhichlookslikethisone :

sometext-othertext

howtoremovethetextincludingdashwithselectstatementsotheresulttobejustsometext?

returnthesubstringbeforethefirstoccurrenceofthedelimiter '-' :

select substring _ index (' foo-bar-bar ','-',1 ) as result;

Outputs result='foo '

you can replace1withthenumbersofoccurrencesyouwantbeforegettingthesubstring

select substring _ index (' foo-bar-bar ','-',2 ) as result;

Outputs result='foo-bar '

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。