MYSQL如何在选择查询中使用修剪 [英] MYSQL How to use trim in select query

查看:78
本文介绍了MYSQL如何在选择查询中使用修剪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的桌子上有大约50条记录,

my table have set of records around 50,

在表中,我有名为USERNAME的列,但是一些用户名前后都有空格

in the table i have column called USERNAME, but some of username leading and trailing have the white space ,

因此由于空格而无法获得确切的订单结果,

so am not getting exact order result because of white space,

所以告诉我如何在SELECT查询中使用修剪,

So tell me how to use the trim in SELECT query ,

谢谢

推荐答案

您可以使用

You can use TRIM in the ORDER BY:

ORDER BY TRIM(username)

...但是这只会修剪文本左侧和右侧的多余空间,而不是两者之间.

...but this will only trim excess space on the left and right side of the text, not in between.

在SELECT中使用TRIM很简单:

Using TRIM in the SELECT is as easy as:

SELECT TRIM(username) AS username
  FROM your_table

这篇关于MYSQL如何在选择查询中使用修剪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆