简体   繁体   English

如果字段等于x,则使用mysql查询在单个表中查找和替换文本

[英]Find and Replace text in a single table using mysql query if a field is equal to x

To find and replace a text in a single table the sql command is: 要在单个表中查找和替换文本,sql命令为:

UPDATE `table_name`
   SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')

I need to find and replace text in field_name if the filed 'language' is equal to "en-GB" 如果归档的“语言”等于“ en-GB”,我需要查找并替换field_name文本

this sql doesn't work: 这个SQL不起作用:

UPDATE `field_name` WHERE `field_name`.`language` = "it-IT"
SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')

Your query should be like this 您的查询应如下所示

UPDATE Table_name SET field_name = replace(field_name, 'unwanted_text', 'wanted_text')
     WHERE language = "it-IT"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 MySQL 查询在整个表中查找和替换整个条目 - Find and Replace entire entries in the entire table using a MySQL query 如何找到文本字段存在于MYSQL表中 - How to find a text field is existing in a MYSQL table 如何在 MySQL 文本字段中查找和替换整个单词? - How to find and replace whole words in a MySQL text field? 在单个查询中查找mysql表中某个条目左右的条目 - find entries to the left and right of a certain entry in a mysql table in a single query 从mysql表的单列中找到等于给定总和的数字组合 - find a combination of numbers that equal a given sum from a single column in mysql table MYSQL单一查询可从一个表中检索单行,也可从另一表中检索多个行作为单个字段 - MYSQL Single query to retrieve both single row from one table and many rows as a single field from another MySQL 查询以在表的任何字段中查找完全匹配 - MySQL query to find an exact match in ANY field of a table MySql为单个查询中的所有提供的X选择field_1,其中X = field_2 - MySql select field_1 where X = field_2 for all supplied Xs in a single query 使用单个查询在更新时自动增加 MySQL 列字段 - Auto-increment MySQL column field on update using a single query 用于数据库查询的单个文本字段 - Single text field for database query
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM