![](/img/trans.png)
[英]mysql query to insert the value of a column with respect to another column in same table
[英]MySQL - if value in column then insert value in another column
我想在我的數據庫上進行批量更新。 所以我想知道如何根據其他列的值將值插入新列。 例如
如果columnA = 15中的值,則在columnB中插入'text'。
謝謝。
多數民眾贊成不插入,即更新,你可以這樣做
update table_name
set
columnB =
case when columnA = 15 then 'text' end
UPDATE table SET columnB = IF(columnA = 15, 'text',NULL);
我從幾乎相似的問題中找到了答案。
UPDATE table
SET columnB='text' where (columnA='15')
這更加直截了當。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.