简体   繁体   中英

Remove numbers from the right of a string in SQL

Is there a function in SQL to remove numbers from the right (in this case, its year) of a string. For example:

Honda elantra - 2019
Ford Mustang - 2017/2018

and the results would just be:

Honda elantra
Ford Mustang

It looks like you want everything before the hyphen -- or ' - ' .

You can use substring_index() :

select substring_index(col, ' - ', 1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM