MySQL 查询 - 在现有数据之前、之后添加字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10704512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL query - Add string before, after existing data
提问by green
I was wondering if someone is able to lend some wisdom about how to accomplish the following task in MySQL.
我想知道是否有人能够就如何在 MySQL 中完成以下任务提供一些智慧。
I need to run a query to add something inside a field before and after the existing data. For example, let's say I have the following data in 'characters.name':
我需要运行查询以在现有数据之前和之后的字段中添加一些内容。例如,假设我在“characters.name”中有以下数据:
'Fred Flintstone'
'Barney Rubble'
How would I insert something, in this example 'xxxxx' before the existing data 'Fred Flinstone' and also 'yyyyy' after the data?
在本例中,我将如何在现有数据“Fred Flinstone”之前插入“xxxxx”,在数据之后插入“yyyyy”?
The result would be:
结果将是:
'xxxxxFred Flintstoneyyyyy'
'xxxxxBarney Rubbleyyyyy'
Any assistance with this would be greatly appreciated.
对此的任何帮助将不胜感激。
Many thanks!
非常感谢!
回答by eggyal
SELECT CONCAT('xxxxx', name, 'yyyyy') AS name FROM characters