test表有3个字段field1(datetime),field2(datetime),field3(datetime) 三个字段都可以为null
field1 field2 field3有7种情况
null null null
null !=null null
null null !=null
null !=null !=null
!=null null null
!=null !=null null
!=null null !=null
!=null !=null !=null当满足1-4种情况我都要insert into 到第二个表test2中
--第一种
insert into test2 select *from test1 where field1 is null and field2 is null and field3 is null
--第二种
insert into test2 select *from test1 where field1 is null and field2 is not null and feild3 is null
--第三种
insert into test2 select *from test1 where field1 is null and field2 is null and field3 is not null
--第四种
insert into test2 select *from test1 where field1 is null and field2 is not null and feid3 is not null判断标准根据field1,field2,field3是否为空
如何简化上面SQL语句
insert into test2 select *from test1 where field1 is null