[英]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. SQL 中是否存在 function 以从字符串的右侧(在本例中为年份)删除数字。 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()
:您可以使用
substring_index()
:
select substring_index(col, ' - ', 1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.