MYSQL更新查询删除空格
我的一位客户在我们的一个应用程序中添加了多个帐号。 尝试进行交易时,由于帐号末尾有空格,交易失败。 我如何更新他在Mysql数据库中的记录,以删除末尾有空格的帐户中的所有空格,而不会让他删除客户端并重新添加帐户?表的结构如下:
不确定如何构造查询或 mysql 的功能
帐户表:
the account table:
CUSTOMER_ID
ACCOUNTNUMBER
TXT
CURRENCY_NO
USER_ID
ACTIVE_FLAG
USER_DATE
ben_bic_address
int_bic_address
the admin table
ADM_USER_ID
LOCATION_CD
LANG
USER_NAME
USER_LOGIN
USER_PASSWORD
GROUP_CODE
USER_ID
USER_DATE
ACTIVE
COUNTER
connected
IP
And the customer table:
CUSTOMER_ID
COUNTRY_NO
USER_ID
CUSTOMER_NAME
ACTIVE_FLAG
One of my clients has added a number of account numbers in one of our applications.
While trying to make a transaction the transaction fails due to the spaces at the end of the account number.
How do i update his records in the Mysql database to remove all the spaces from accounts that have them at the end, without making him delete the clients and re-adding the accounts? the structure of the table(s) is as follows:
Not sure how to structure the query or the function of the mysql
The account table:
the account table:
CUSTOMER_ID
ACCOUNTNUMBER
TXT
CURRENCY_NO
USER_ID
ACTIVE_FLAG
USER_DATE
ben_bic_address
int_bic_address
the admin table
ADM_USER_ID
LOCATION_CD
LANG
USER_NAME
USER_LOGIN
USER_PASSWORD
GROUP_CODE
USER_ID
USER_DATE
ACTIVE
COUNTER
connected
IP
And the customer table:
CUSTOMER_ID
COUNTRY_NO
USER_ID
CUSTOMER_NAME
ACTIVE_FLAG
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您需要
RTRIM()
特定客户的所有帐户,您可以将JOIN
与 UPDATE 语句结合使用,如下所示:如果您的 account_table 中没有很多记录,并且您想要确保所有
accountnumber
值都被修剪,您可以简单地将修剪应用于所有记录,如下所示:If you need to
RTRIM()
all the accounts of a particular customer, you can use aJOIN
with your UPDATE statement as follows:If you do not have many records in accounts_table, and you want to make sure that all the
accountnumber
values are trimmed, you can simply apply the trim to all the records as follows:您将使用 TRIM 和更新。
只需使用这个就可以了。
You would use TRIM and update.
Just using this should do it.
如果您有外键约束,那么您可能必须在进行修改时删除它们。
以下查询将更改accounts表中的记录:
If you have foreign key constraints, then you may have to remove them whilst you make the modifications.
The following query will change the records in the accounts table:
尝试这个
TRIM() 函数从字符串中删除多余的空格。
结果:
Product_quantity = " 50 " => 50
Try this
TRIM() Function removes extra (or) additional spaces from a string.
Result:
Product_quantity = " 50 " => 50