MySQL 使用 sql 查询将文本添加到字段

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5107263/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:54:07  来源:igfitidea点击:

Add text to a field with sql query

mysqlconcatenationconcat

提问by Ivar

I have a field in the mysql database and I would like to insert text in front of all the values in that field.

我在 mysql 数据库中有一个字段,我想在该字段中的所有值前面插入文本。

I would like to add "F21 - " So the field would be "F21 - product name" instead of "product name"

我想添加“F21 - ”所以该字段将是“F21 - 产品名称”而不是“产品名称”

I need a simple sql query

我需要一个简单的 sql 查询

any ideas?

有任何想法吗?

回答by UltraInstinct

Use concat. Something like this:

使用连接。像这样的东西:

update mytable set myfield = concat('f21 -',myfield)