简体   繁体   English

如何用MySQL查询替换列的值

[英]How to replace value of column with MySQL Query

I try to make some changes to my MySQL database, and I need to change values of this col name "id_lang" which values now is "6" to change to value "2". 我试图对我的MySQL数据库进行一些更改,并且我需要更改此col名称“ id_lang”的值,该值现在为“ 6”才能更改为值“ 2”。

This col is found in many tables, it will be great to have a single query which will to this for all DB at once. 在许多表中都可以找到该列,最好有一个查询,一次查询所有数据库。

by now i found this query, 到目前为止,我发现了这个查询,

SELECT REPLACE(yourcolumn,'ValueInTheColumnTobeReplaced', 'NewValue')  as replacedColumnName FROM yourtable

PS: I use PHPMYADMIN PS:我使用PHPMYADMIN

but i cant make it work... PLease help me!!! 但是我不能使它工作...请帮帮我!!!

You have to use an Update query. 您必须使用Update查询。

But you can not do this in one query for all tables. 但是您不能在一个查询中对所有表执行此操作。

Update yourTable set id_lang=2  where id_lang=6

使用此查询

 UPDATE yourTable SET id_lang=2 WHERE id_lang=6;

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM