MySQL-如果列中有值,则在另一列中插入值

MySQL-如果列中有值,则在另一列中插入值,mysql,Mysql,我想对我的数据库进行批量更新。所以我想知道如何根据其他列的值向新列插入值。例如 如果A列中的值=15,则在B列中插入“文本” 谢谢。这不是插入,而是更新,您可以按需要执行 update table_name set columnB = case when columnA = 15 then 'text' end 我从几乎相似的问题中找到了答案 UPDATE table SET columnB='text' where (columnA='15') 这更为直截了当 UPDATE table

我想对我的数据库进行批量更新。所以我想知道如何根据其他列的值向新列插入值。例如

如果A列中的值=15,则在B列中插入“文本”


谢谢。

这不是插入,而是更新,您可以按需要执行

update table_name
set 
columnB = 
case when columnA = 15 then 'text' end

我从几乎相似的问题中找到了答案

UPDATE table
SET columnB='text' where (columnA='15')
这更为直截了当

UPDATE table SET columnB =  IF(columnA = 15, 'text',NULL);