可以在 MySQL 字段中的“空格"后删除所有内容吗? [英] Possible to delete everything after a 'space' in MySQL field?
本文介绍了可以在 MySQL 字段中的“空格"后删除所有内容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有以下字段:
'名字子_blah'
我可以使用 TRIM() 函数去除外部空格,但我实际上希望删除第一个空格之后(修剪之后)的所有内容.
I can get rid of the outside spaces with the TRIM() function but I am actually looking to remove everything after the first space (after the trim).
所以:
'name sub _blah' 会变成 'name'
'name sub _blah' would turn into 'name'
我知道这在 PHP 中是可能的,但我正在尝试仅使用 MySQL 调用.有什么我不知道的功能吗?
I know this is possible in PHP but I am trying to do on a MySQL only call. Is there a function I do not know about for this?
谢谢!
推荐答案
select substring_index('name sub _blah',' ',1)
这篇关于可以在 MySQL 字段中的“空格"后删除所有内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文