2016-05-12 84 views
0

我有一個表,products與列descriptiondescription_short 我的一些產品有description空和description_short填充,反之亦然,有些甚至可能都填滿。所以我想要做的是複製所有填充的descriptiondescription_short,其中description_short是空的。MySQL的插入從一列到另一個如果不存在

用MySQL做這件事最簡單的方法是什麼?

回答

0

這很簡單:

update products 
set description = description_short 
where description is null; 

commit; 

update products 
set description_short = description 
where description_short is null; 

commit; 
0
update table_name 
set description_short =description 
where description_short is null and description is not null 
相關問題