当使用insert into将数据加载到sql上的一列时,如何排除空值?

问题描述 投票:0回答:1

我在 Mac 上使用 azure data studio。

我想把数据从另一个表加载到我创建的新表中,原表的列中包含了一些空值,而我的新表是不应该有的.我怎么做插入并排除空值?

insert into [Faculty].[Department](
    DepartmentName,
    DepartmentCode
)
select departmentName, departmentCode
from [].[]

但我想让我的新表排除空值,我试过一个where语句,但没有成功,请帮助:(

sql macos sql-insert azure-data-studio
1个回答
0
投票

不知道你用的是什么数据库.可以试试下面的。

insert into [Faculty].[Department](
         DepartmentName,
         DepartmentCode
     )
     select departmentName, departmentCode
     from anothertable 
     where anothertable.col is NOT null
© www.soinside.com 2019 - 2024. All rights reserved.