Update only in case where its not null
This question already has an answer here:
您可以使用此查询来实现您的约束。
Update ExpressMarketCheck set Barcode = (select barcode from ExpressMarket where barcode IS NOT NULL)
mySQL具有IFNULL
功能,所以你可以这样做:
UPDATE your_table_name
SET your_column_name= "data",
scan_created_date = ISNULL( your_column_name, "data" )
WHERE id = X
I think you want a join
:
update emc
set Barcode = em.barcode,
Name = em.name,
price= em.price
from ExpressMarketCheck emc join
expressmarket em
on emc.?? = em.??;
I cannot tell from your question what columns should be used for the join
. The ??
are placeholders.
上一篇: 在保存在列中的表名称的表内更新
下一篇: 只在其不为空的情况下更新