如何删除MySQL字段中的前导和尾随空格? [英] How to remove leading and trailing whitespace in a MySQL field?

查看:105
本文介绍了如何删除MySQL字段中的前导和尾随空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两个字段(国家和ISO代码)的表:

I have a table with two fields (countries and ISO codes):

Table1

   field1 - e.g. 'Afghanistan' (without quotes)
   field2 - e.g. 'AF'(without quotes)

在某些行中,第二个字段在开头和/或结尾处都有空格,这会影响查询.

In some rows the second field has whitespace at the start and/or end, which is affecting queries.

Table1

   field1 - e.g. 'Afghanistan' (without quotes) 
   field2 - e.g. ' AF' (without quotes but with that space in front)

(在SQL中)有没有一种方法可以遍历表格并在field2中查找/替换空白?

Is there a way (in SQL) to go through the table and find/replace the whitespace in field2?

推荐答案

您正在寻找 查看全文

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