更改MySQL字符串中的特定字符 [英] Changing a specific char in a MySQL string
本文介绍了更改MySQL字符串中的特定字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个具有一系列权限的表,我需要在字符串的给定位置p中将每个用户的权限更改为Y,是否可以使用SQL命令或者必须编写程序/脚本?要做吗?
I have a table with a series of permissions, and I need to change every user's permission to Y in a given position p in the string, is there a SQL command I can use or do I have to write a program/script to do it?
推荐答案
您可以在MySQL中结合使用concat和substring:
You can use a combination of concat and substring in MySQL:
mysql> select concat(substring('12345',1,3),'A',substring('12345',5));
+---------------------------------------------------------+
| concat(substring('12345',1,3),'A',substring('12345',5)) |
+---------------------------------------------------------+
| 123A5 |
+---------------------------------------------------------+
您可以将"12345"替换为列名.
You can replace '12345' with the name of your column.
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html
这篇关于更改MySQL字符串中的特定字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文